3

I'm sending an email from ASP.NET using MailMessage and SmtpClient. I want to introduce some line breaks but none of the following worked:

  • Adding tags sbBody.Append("<table width='100%'><tr><td></br></br>");
  • Adding \r\n sbBody.Append("<table width='100%'><tr><td>\r\n\r\n");
  • Appending a new line to the StringBuilder.

sbBody is a StringBuilder wich I use at the end to set MailMessage's body: mailMessage.Body = sbBody.ToString()

What Am I missing here? I'm viewing the emails in Outlook and off course I'm setting IsBodyHtml to true.

Thanks for your time.

EDIT: Solved, it was a syntax error, </br> instead of <br/>

Jim G.
  • 14,056
  • 19
  • 94
  • 153
daniloquio
  • 3,636
  • 1
  • 31
  • 55
  • 1
    Sometimes you have to tell Outlook to show additional line breaks. – jrummell Apr 24 '12 at 14:41
  • These SO answers might be helpful: http://stackoverflow.com/questions/247546/outlook-autocleaning-my-line-breaks-and-screwing-up-my-email-format http://stackoverflow.com/questions/136052/how-do-i-format-a-string-in-an-email-so-outlook-will-print-the-line-breaks http://stackoverflow.com/questions/3931409/mailmessage-sent-string-as-body-without-newline-in-outlook – Kibria Apr 24 '12 at 15:03

1 Answers1

9

Your br tags are wrong. They should be written as:

<br />
Jim G.
  • 14,056
  • 19
  • 94
  • 153