Carriage returns in MailMessage object

G

Guest

Hi,
I'm using the MailMessage object to send an email programmatically via a
console application. It needs to have lines breaks. For example:

string s = "This is the first line + "\n\r" + "and this is the second line.";

This works fine when written to the console however the MailMessage object
ignores the \ escape key and returns a single lined string.

How can I use carriage returns in a MailMessage?

Many thanks in advance.
 
G

Guest

Hi,

well, I tried both your solutions. "\r\n" gives the same result as "\n\r"
and Enviroment.NewLine, is also treated the same. I'm guessing that because
the email is HTML, it needs a <BR>. Does anybody know how I can send a <BR>
in a string?

Many thanks for your thoughts on this

Ant
 
G

Guest

Actually, I inadvertently answered my own question. Because it is treating
the text as HTML, I simply added the break to the string i.e.

"This is the text<BR>This is the next line."

and it wote it to the email with the breaks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top