?
Solved

System.Net.Mail & additional fields

Posted on 2008-11-19
2
Medium Priority
?
230 Views
Last Modified: 2012-06-27
I understand how to send mail using MailMessage, but what if I want to add additional fields to the body of the email, say a telephone and fax number, or any number of fields?  I think it should go in the body, but I am not getting all to show correctly on the email.  Can someone explain how I might expand what can be sent in the email body?  Below is the code I am starting with.

Using .NET 2.0 and VB.
Thanks
Rick

Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        'Email address to send contact for to
        Const ToAddress As String = "me@myself.com"
        
        'Create the MailMessage instance
        Dim mm As New MailMessage(tbEmail.Text, ToAddress)
 
 
        'Assign the MailMessage's properties
        mm.Subject = dlSubject.Text
        mm.Body = tbComments.Text
        mm.IsBodyHtml = False
 
        'Create the SmtpClient object
        Dim smtp As New SmtpClient
 
        'Send the MailMessage using the Web.config settings)
        smtp.Send(mm)
 
        'Show the EmailSentForm Panel and hide the EmailForm Panel
        EmailSentForm.Visible = True
        Me.contactform.Visible = False
        'ContactForm.Visible = False

Open in new window

0
Comment
Question by:simprick
2 Comments
 
LVL 13

Accepted Solution

by:
TechTiger007 earned 1000 total points
ID: 22996100
Mail body will take a string (plain text or HTML) that will be displayed as the email message.

If you want to include more data in the email body you can construct a string that includes all the data to be displayed and in the specific format and finally assign the string to mail body.

Something like below

dim mailbody as string
mailbody = tbComments.Text & Environment.NewLine
mailbody &= "Telephone number : " & txtTelephoneNumber.Text & Environment.NewLine
mailbody &= "Address : " & txtAddress1.Text & Environment.NewLine

If you want to have more control over the mail body you can use HTML format
mailbody &= "<b>Telephone Number :  </b>" & txtTelephoneNumber.Text & "<br/>"
...
...

then you have to set mm.IsBodyHtml = true
0
 
LVL 2

Author Closing Comment

by:simprick
ID: 31518303
Thanks much, I think html will be they way to go on the final product.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question