Search code examples
c#.netwinformssmtpoutlook-2013

the email body removing all lines break (windows form )


i'm generating a simple email in windows form application using the

 System.Net.Mail.MailMessage 

and i can't add new line to email body , I've tried almost all possible things so far, like :

Environment.Newline

"\n" , "\t" , "\r\r"

 Regex.Replace(body, @"(?<!\t)((?<!\r)(?=\n)|(?=\r\n))", "\t", RegexOptions.Multiline);

Solution

  • Email body is actually read as an HTML. So you should use HTML tags to accomplish your body design.

    Use <br> tag for changing the line.

    MailMessage.IsBodyHtml must be set to true to render it as an HTML email.