PC Review


Reply
Thread Tools Rate Thread

Help! MailMessage Body is stripping carriage return/line feeds

 
 
Tim Mavers
Guest
Posts: n/a
 
      27th Feb 2004
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!
 
Reply With Quote
 
 
 
 
Bill
Guest
Posts: n/a
 
      27th Feb 2004
You must use "\r\n"

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

Bill


"Tim Mavers" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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!



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 stripping out line feeds PJ Microsoft Excel Programming 3 6th May 2008 10:42 PM
Carriage returns in MailMessage object =?Utf-8?B?QW50?= Microsoft C# .NET 4 21st Dec 2005 08:16 AM
Stripping Out Carriage Returns Gina Microsoft Access Queries 2 21st Mar 2004 03:06 PM
Help! MailMessage Body is stripping carriage return/line feeds Tim Mavers Microsoft C# .NET 1 27th Feb 2004 10:14 PM
Help! MailMessage Body is stripping carriage return/line feeds Tim Mavers Microsoft Dot NET Framework 1 27th Feb 2004 10:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:13 AM.