StackTrace StackTrace - 9 months ago 28
Vb.net Question

Concatenate text on 3 different textboxes to make bulleted list in email using VB.NET

i have 3 textboxes on an asp.net page and i would like to send the text on all those textboxes as an email message body when a button is clicked. I want each text on each textbox to appear on a new line(this i can do), but i also want the lines to be bulleted. Something like


  • Text on Textbox1

  • Text on Textbox2

  • Text on Textbox3



Thank you in advance.

Answer Source

If you are happy with HTML in the message body then create a HTML unordered list as follows:

C#:

StringBuilder body = new StringBuilder()
        .Append("<ul><li>")
        .Append(txtBoxOne.Text)
        .Append("</li><li>")
        .Append(txtBoxTwo.Text)
        .Append("</li><li>")
        .Append(txtBoxThree.Text)
        .Append("</li></ul>");

MailMessage mMailMessage = new MailMessage();
mMailMessage.Body = body.ToString();
mMailMessage.IsBodyHtml = true;

VB.NET:

 Dim body = New StringBuilder()
 body.Append("<ul><li>")
 body.Append(txtBoxOne.Text)
 body.Append("</li><li>")
 body.Append(txtBoxTwo.Text)
 body.Append("</li><li>")
 body.Append(txtBoxThree.Text)
 body.Append("</li></ul>")

 Dim mMailMessage = New MailMessage()
 mMailMessage.Body = body.ToString()
 mMailMessage.IsBodyHtml = True