How to Insert Line Breaks When Emailing?

Topics: ASP.NET 2.0, Business Logic Layer, Controls, Themes
Sep 28, 2012 at 5:26 PM
Edited Sep 28, 2012 at 5:27 PM

Neither the "\n" or "<br />" are working. I'm trying to insert line breaks when emailing the contents of a custom form:  

protected void SubmitBtn_Click(object sender, EventArgs e)
{
    if (Page.IsValid)
    {
        StringBuilder mailBody = new StringBuilder();
        mailBody.Append("Company Name: " + companyText.Text.Trim() + "\n\n");
        mailBody.Append("Name: " + firstNameText.Text.Trim() + " " 
+ lastNameText.Text.Trim() + "\n\n"); mailBody.Append("Email: " + emailText.Text.Trim() + "\n\n"); if(!String.IsNullOrEmpty(tradeText.Text)) mailBody.Append("Trade: " + tradeText.Text.Trim() + "\n\n"); bool success = SendEmail(emailText.Text.Trim(), companyText.Text.Trim(),
"SubContractors Form Submission"
, mailBody.ToString()); } }

private
bool SendEmail(string email, string name, string subject, string message) { using (MailMessage mail = new MailMessage()) { mail.From = new MailAddress(BlogSettings.Instance.Email, name); mail.ReplyTo = new MailAddress(email, name); mail.To.Add(BlogSettings.Instance.Email); mail.Subject = subject; mail.Body += message; if (Utils.SendMailMessage(mail).Length > 0) { return false; }; } return true; }
Sep 28, 2012 at 8:57 PM

Answer I received on StackOverflow:

You can use: