473,397 Members | 2,028 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,397 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!
Nov 15 '05 #1
1 7087
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!

Nov 15 '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: 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...
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...
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...
8
by: kcovert | last post by:
using System.Net.Mail; I've been unable to get a carriage return/line feed into the body of my Outlook message. Have look all over the web for a soltion with no luck. Here's what I have tried...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.