How to add several form field values to email being sent in vb.net?

I have a form that sends an email when the submit button is clicked.  I'd like to include the values from the form into the text of the email, but I don't know how to do that.  Below is the code I have to send the email... How do I add all the form values to the message text  (mm.Body) and include line breaks or spacing to layout the form values for easy reading? 

Protected Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit.Click
Const ToAddress As String = "foo@foo.com"
Dim mm As New MailMessage("foo@foo.com", ToAddress)
mm.Subject = "New Conflict Search"
mm.Body = ????
mm.IsBodyHtml = False
Dim smtp As New SmtpClient
smtp.Send(mm)
End Sub


Never make important decisions on a Monday!
0
funluckykitty
4/24/2008 4:52:18 PM
asp.net.getting-started 91979 articles. 3 followers. Follow

7 Replies
720 Views

Similar Articles

[PageSpeed] 8

Dim sBody as string
sBody=TextBox1.Text & " - " & TextBox2.Text & " - " & TextBox3.Text

mm.Body=sBody

(or you can do it directly, without the variable)


David Wier
MCP/ASPInsider
ASPNet101.com - where to look first!
Please Vote for ASPNet101 - 'Best Community Resource'!
Control Grouper - easily control properties for multiple controls with one control!
Calendar Express - The Best HTML Calendar Generator on the web!
(Please 'Mark as Answer' when it applies)
0
augustwind
4/24/2008 5:02:19 PM

mm.Body = "Text Box Value: " & TextBox1.Text & "<br />Drop Down List Value:  " & DropDownList.SelectedValue & "<br />"

Does this help?

0
msnyder0
4/24/2008 5:04:56 PM

Thank you augustwind and msnyder()...   Works great...  :-)


Never make important decisions on a Monday!
0
funluckykitty
4/24/2008 5:06:39 PM
I always find great help here.   Is it possible to write in the email the displayed value from a drop down list instead of the data value?  In other words, if I have a list of people by alphabetical, I insert their person ID when the form is submitted, but in the email, I'd rather include their name instead of their id. 
Never make important decisions on a Monday!
0
funluckykitty
4/24/2008 5:18:58 PM

ddl.SelectedItem.Text


David Wier
MCP/ASPInsider
ASPNet101.com - where to look first!
Please Vote for ASPNet101 - 'Best Community Resource'!
Control Grouper - easily control properties for multiple controls with one control!
Calendar Express - The Best HTML Calendar Generator on the web!
(Please 'Mark as Answer' when it applies)
0
augustwind
4/24/2008 5:26:21 PM
HOLY COW... That was super simple..  You've just made my day.  THANK YOU augustwind!!!!!!! 
Never make important decisions on a Monday!
0
funluckykitty
4/24/2008 5:28:46 PM

Oh soo close.. Now, I'm getting this error when trying to set the body of the email.  Some of the form fields are hidden/visible and this depends on the users answer to a radio button list at the beginnig of the form.  Is this error due to some fields not being populated when the user submits the form because they are hidden, and therefor not asked.. or did I mess up the syntax of the body of the email.    (My Code is below) 

 Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:

Line 17: 
Line 18:         Dim sBody As String
Line 19:         sBody = "Type of search:  " & tSearchTypeID.SelectedItem.Text & "<BR/><HR><BR/>Requesting Attorney:  " & RequestingAttorney.SelectedItem.Text & "<br/><HR><br/>Name(s) of Potential Client:  " & PotentialClient.Text & "<BR/>Name(s) of Other Parties:  " & OtherParties.Text & "<BR/><HR><br/>Names to search in the database:  " & NamesToSearch.Text & "<br/><HR><br/>Name(s) of Other Related Parties" & OtherRelatedToSearch.Text & "<br/><HR><br/>Client Name:  " & ClientToSearch.SelectedItem.Text & "<BR/><HR><BR/>Names of entities to be searched:  " & EntitiesToSearch.Text & "<BR/><HR><BR/>Existing batch number:  " & ExistingBatchNumber.Text & "<br/><br/>Additional names to be searched:  " & AdditionalNames.Text
Line 20: 
Line 21: 

From my code behind..

sBody = "Type of search: " & tSearchTypeID.SelectedItem.Text & "<BR/><HR><BR/>Requesting Attorney: " & RequestingAttorney.SelectedItem.Text & "<br/><HR><br/>Name(s) of Potential Client: " & PotentialClient.Text & "<BR/>Name(s) of Other Parties: " & OtherParties.Text & "<BR/><HR><br/>Names to search in the database: " & NamesToSearch.Text & "<br/><HR><br/>Name(s) of Other Related Parties" & OtherRelatedToSearch.Text & "<br/><HR><br/>Client Name: " & ClientToSearch.SelectedItem.Text & "<BR/><HR><BR/>Names of entities to be searched: " & EntitiesToSearch.Text & "<BR/><HR><BR/>Existing batch number: " & ExistingBatchNumber.Text & "<br/><br/>Additional names to be searched: " & AdditionalNames.Text



Never make important decisions on a Monday!
0
funluckykitty
4/24/2008 7:18:02 PM
Reply:

Similar Artilces:

Need way to edit vb.net form values that have been sent to email address.
I have a vb.net web form that sends its values to an email address. I have been asked to see if there is a way to modify the form so that the user who receives the email can edit the form values and then forward the modified values to another email address (without having to save the file locally first). In addition, for printing purposes, the email that the user receives must be formatted to look exactly like the web form, including the form values. Is this even possible?My current page sends the form values to a pre-formatted .htm file that is created on our server. An ema...

how to design vb.net form with two fields that need to have ability to add a limitless number of values.
I have a form with 5 textboxes and 2 fields that need to have an endless number of options and I just don't know how to deal with this all on one form.  Questions 1-5 are basic demo graphic questions about a person (Name, address, etc) Question 6 asks you to provide insurance beneficiaries and their percentage, and there is no limit to the number of insurance beneficiaries you can have.  (You could list 100 beneficiaries, with each getting 1%) Question 7 asks the user to provide 401k benficiaries and their percentage, and again, there is no limit to the number you can have, ...

getting start with vb.net and crystal repots(web form)
I use Crystal Report9 in Visual Studio.NET 2003..... Example at Northwind database I want a application that.....a form include a combobox that contain CustomerID.....If I choose one CustomerID and click OK button....a Report will display information about this Customer......I think that must use Paramater.....how to do that ???? (How do I start to coding --please step by step or sample) please help me !!! Thank you so much!!! very good I have Dropdownlist when I choose the 'month'--> the all data of this field will show I use this Private Sub ddlMonth_Sel...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

VB.net add textbox values together to get total
Hi Guys Im using visual studio 2005 vb.net. sql express, im a newbie and im basically trying to create a customer calculator. Ive got this code, basically i want to add the integer values of each of my text boxes together and then display them in a textbox called textbox1.  I think i have the code write to do the calculation but im stuck on how to get it to display the total in the textbox once ive hit the calculate button, ive tried several ways, the page posts back, i get no errors but nothing in textbox1 toocan you take a look and help me out please. Thanks and Kind Regards &...

How to get the value of a textbox that has been added to a template field in a gridview. VB.Net
I have a gridview that shows products, description, price. I have added a Buttonfield and a TemplateField that has a Textbox with the id QuantityTextBox.What I am trying to do is get the value of the Quantity TextBox in the RowCommand event of the gridview. I can get the price but need to get the quantity also. To get the price I used ItemPrice = Server.HtmlDecode(row.Cells(5).Text) My template field is cell 6 but the above routine does'nt work. Any help would be greatly appreciated.Dan5150www.5150creations.com Hiuse this: VB:  Protected Sub GridView1_RowCommand(ByVal ...

How to get RS (From VB6) to .NET (VB.NET)
Hi Friends,         I have requirement, there is one function in VB6 it returns a RS, I need to call that function in  VB.NET, how to get those values into .NET, if can any body can help (pass me some code snippets), that will be greate, Thank you.Madhu... -Madhu hey guys i got this one just by using fill method.-Madhu...

converting to vb.net from c#.net authorize.net
authorize.net offered me some sample code when I signed up with them the only problem is the sample code is in c#.net but my page that they type all of their credit card into is vb.net <code><%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %> <script language="C#" runat="server"> void Page_Load(Object Src, EventArgs E) { myPage.Text = readHtmlPage("https://certification.authorize.net/gateway/transact.dll"); } private String readHtmlPage(string url) { ...

How do I get the Identity field value after a sql insert so the value can be included in the email sent upon submit?
I have  a form that gathers a bunch of data, inserts into a sql database via a stored procedure, and then emails a user some details.  How can I include the value of the unique identifier for the row just inserted into sql in the email?    Here's my code behind.. and I don't know how/where to query the db to get the value and insert it... Protected Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit.Click InsertConflictSearch.InsertParameters("SearchStatusID").DefaultValue = "1"InsertConflictSearch.Insert...

ADO.NET table fields pass to a VB.NET variable
Hi, please help, have a ADO.NET code. 1 Dim conn As New Data.SqlClient.SqlConnection 2 Dim sql As New Data.SqlClient.SqlCommand 3 4 conn = New Data.SqlClient.SqlConnection("Provider=SQLOLEDB.1;Password=dbsystematics;Persist Security Info=True;User ID=sa;Initial Catalog=SARS;Data Source=4G") 5 conn.Open() 6 sql = New Data.SqlClient.SqlCommand("select * from users", conn)   Then i would like to pass the values that the above ADO.NET to a variable.how?please help. JFRBPH12™ You can execute the ...

How to Add Applications to ADAM using vb.net or C#.net
 Hi Pls thrown light  any one on How to Add Applications to ADAM using vb.net or C#.net RegardsMallikarjunaP.Mallikarjuna...

getting value from string (VB .net)
HiJust a quickie (i hope) - i'm trying to get a value from a string but not sure what method to use.Eg Dim myString As String = "(ng) nottingham"How would i get the value between the parentheses - ng?  The values are either going to be a single or two characters if this helps?I can think of a work around using myString.IndexOf() but i'm sure there must be a specific function for this problem? thanks  Hey, You could loop through the three or four characters, use the Substring method and trim/remove the parens, or you can use regular expressions.Brian"Trust in the Lord a...

vb.net vs c#.net vs j#.net
just out of curiousity which looks, acts most like java? i'm still learning trying to used to vb.net but it seems that it was easier to do some stuff with java. C# is Java++ in my opinion. If you have done C or Jave you will prefer C#.Mike Schellenberger - MCAD If you are looking for language similar to java go for J#. However most code samples you find on the net will be in VB.NET and C#....

how can i Get OCX File in .net IDE vb.net/C3
hi all,      How can I generate OCX file in VB.net/c# 2005 that will interact in web pages...?Thanks & Regards,Murthy. Hi murthysrn, As far as I know, VB 2005 and C# 2005 cannot create the project for ocx file. However, I hope the following link will be helpful to you. Creating an ActiveX Control in Visual Studio 2005http://msmvps.com/blogs/pauldomag/archive/2006/08/16/107758.aspxSincerely,Benson YuMicrosoft Online Community Support Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other co...

Web resources about - How to add several form field values to email being sent in vb.net? - asp.net.getting-started

Donald Trump Blasts TIME For Not Naming Him Person Of The Year
Donald Trump really doesn't like losing TIME's Person of the Year to Angela Merkel. The leading GOP Presidential contender and former Apprentice ...

Just-released Star Wars TV ad and teaser video include exciting new footage
Nine days. That’s just a little over a week of waiting until Star Wars: The Force Awakens finally hits theaters. But Disney is far from done ...

Yahoo wants to spin-off Yahoo, become a holding company for Alibaba shares
Marissa Mayer, CEO of Yahoo. (credit: Google+ ) One of Yahoo’s best decisions was investing in a large chunk of Chinese e-commerce company Alibaba ...

The Nexus 6 disappears from the Google Store
The Nexus 5X and 6P began shipping in October and now that sales are well underway, Google is bidding adieu to the Nexus 6. The Google Store ...

Microsoft launches Cortana for Android and iOS, but only in the U.S. and China
Microsoft has officially launched Cortana for Android and iOS — but only in the U.S. and China. The computing giant first revealed plans to ...

Uber trials bus-like service in Seattle, and wants everyone in Chicago to be an Uber driver
It’s hard to knock Uber when it looks like it’s trying to ensure there are fewer, not more, cars on the roads in our cities. And its latest pilot ...

There's one simple way the guy named as the creator of bitcoin could prove his identity
On Wednesday, Gizmodo and Wired published twin bombshell reports alleging they had identified the inventor of bitcoin. Known only by the pseudonym ...

HTC Vive VR headset release date pushed back to April
On December 8, HTC announced that their VR headset, initially scheduled for release before the new year, will now be released in Spring 2016. ...

German Chancellor Angela Merkel is Time Mag’s Person of the Year: good call?
I was actually hoping that this year’s Time Magazine Person of Year would actually go to one person, rather than a group, and that the person ...

Google, NASA: Our quantum computer is 100 million times faster than normal PC
(credit: D-Wave) Two years ago Google and NASA went halfsies on a D-Wave quantum computer , mostly to find out whether there are actually any ...

Resources last updated: 12/9/2015 4:11:57 PM