Help! MailMessage Body is stripping carriage return/line feeds

  • Thread starter Thread starter Tim Mavers
  • Start date Start date
T

Tim Mavers

I am using the MailMessage class and am dynamically building the message
body field. I know I am using String and not String builder but I don't
want to worry about that now. The problem is after I build my message
(which contains CR\LFs -- blank lines), the message received by the user
has all the cr\lf's removed from the message body so that everything is
on one line.

I have tried using "\n", "\n\r", Environment.NewLine, and
Environment.NeLines.ToString() (only because I saw this last method on
Google).

Anyway, I have viewed the message in Outlook and Outlook Web Access
(through IE 6) and they look the same, so I am pretty confident the
client is not removing anything. Here's a quick sample of the code:

String msgBody = "The following information was received by the fax
server.:" + Environment.NewLine.ToString() + Environment.NewLine.ToString();

---sample code---
msgBody += "Date: " + data.Date + " " + data.Time +
Environment.NewLine.ToString();

msgBody += "Machine: " + data.Computer + Environment.NewLine.ToString();

msgBody += "User: " + Environment.NewLine.ToString()

msgBody += "File: " + data.ObjectName + Environment.NewLine.ToString();
---sample code---

Again, when I receive this message the entire message above is all on
one line.

Is there a C# equivalent of the old VbCrLf (I assumed it was
Environment.NewLine?

Any other ideas?

Thanks!
 
You must use "\r\n"

Also if you are using in HTML use "<BR>" instead. (This is a common
mistake.)

Bill
 
Back
Top