In my application I place standard mail messages in web.config .
But if message contains '\n' and mail is sent, it doesn't implement as newline character in mail body.

System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
            mail.To = to;
            mail.From = From;
            mail.Subject = subject;
            mail.BodyFormat = MailFormat.Html;
            mail.Body = body;
            System.Web.Mail.SmtpMail.SmtpServer = "localhost";  //your real server goes here
            System.Web.Mail.SmtpMail.Send( mail );

Any suggestion?

Recommended Answers

All 2 Replies

Since you have set the BodyFormat as MailFormat.Html, you can use <br> for new line.

Also, you could wrap all your text in <p></p> tags, as they automatically get a newline between them and any other objects.

When I've done things like this, I set up an HTML template via code, and just input variables into the template, then sent it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.