How do I add carriage returns to an email in C#?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using system.web.mail to send an email in asp.net (c#). I would like to
format the body of the email message so that it includes carriage returns
(and indentation if I can go for broke). Can someone give me an example of
how to do this? Thanks!
 
Hello jacobryce,

Use "Environment.NewLine".

StringBuilder sb = new StringBuilder("");
sb.Append("Hi Mom,");
sb.Append(Environment.NewLine).Append(Environment.NewLine); // inserts 1
blank line
sb.Append(" "); // for indentation
sb.Append("I am fine. Having fun.");
String mymailmessage = sb.ToString();

Output would look like:

Hi Mom,

I am fine. Having fun.

Raymond Lewallen
http://www.dotnetjunkies.com/weblog/rlewallen
 
Back
Top