473,326 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Help! MailMessage Body is stripping carriage return/line feeds

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!
Jul 21 '05 #1
1 4357
You must use "\r\n"

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

Bill
"Tim Mavers" <we*****@hotmail.com> wrote in message
news:Br********************@giganews.com...
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!

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: | last post by:
Hi, I want to send an Email using ASP (I know how to to this) The body of the Email contains several variabels How do I concat string values and separate them by carriage returns/ Line feeds? ...
1
by: wschaub | last post by:
Is there any way of forcing an ASMX web service not to translate a carriage return – line feed (\r\n) with a (\n\n), in other words the carriage return \r is replaced with a \n if contained as...
1
by: Tim Mavers | last post by:
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...
2
by: John Dalberg | last post by:
Hi What's the regex to remove the carriage return/line field from a string? These can occur multiple times in the string as in xxx\r\n\r\n. -- John Dalberg
2
by: Torsten Zachert | last post by:
I would like to insert some text with embedded carriage return/line feed into a MS Access text field with OleDb and C# ADO.NET. I tried to use "\n" in combination with "\r". If I display the input...
0
by: John Dalberg | last post by:
I noticed that when I add key/value pairs to a NameValueCollection variable and send this collection through a POST using WebClient.UploadValues method, the recepient process receives the...
0
by: J.Marsch | last post by:
I am having a problem in which ASP.Net web services are corrupting my data. I know that my problem is related to the standard way of encoding carriage return linefeeds, so I need to figure out how...
2
by: Enrico Sabbadin | last post by:
Hi, A few days go I fiund iut that the xmlserializer strips away /r/n out during deserialization (and just leave /n) ... I found out that you can resolve this problem using the deserialize...
0
by: Hayduke | last post by:
I've observed various posts here and elsewhere concerning CRLFs getting stripped out of programatically generated emails. This behavior is evident when the email is viewed using various versions of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.