Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line break doesn't work in MailMessage's body

Tags:

html

c#

asp.net

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/>

like image 406
daniloquio Avatar asked Jan 19 '26 21:01

daniloquio


1 Answers

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

<br />
like image 132
Jim G. Avatar answered Jan 21 '26 12:01

Jim G.