473,487 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Carriage returns in MailMessage object

Ant
Hi,
I'm using the MailMessage object to send an email programmatically via a
console application. It needs to have lines breaks. For example:

string s = "This is the first line + "\n\r" + "and this is the second line.";

This works fine when written to the console however the MailMessage object
ignores the \ escape key and returns a single lined string.

How can I use carriage returns in a MailMessage?

Many thanks in advance.

Dec 20 '05 #1
4 1811
try Environment.NewLine?

"Ant" <An*@discussions.microsoft.com> wrote in message
news:2F**********************************@microsof t.com...
Hi,
I'm using the MailMessage object to send an email programmatically via a
console application. It needs to have lines breaks. For example:

string s = "This is the first line + "\n\r" + "and this is the second
line.";

This works fine when written to the console however the MailMessage object
ignores the \ escape key and returns a single lined string.

How can I use carriage returns in a MailMessage?

Many thanks in advance.

Dec 20 '05 #2
Please use "\r\n" or Environment.NewLine

--
Vince

Dec 20 '05 #3
Ant
Hi,

well, I tried both your solutions. "\r\n" gives the same result as "\n\r"
and Enviroment.NewLine, is also treated the same. I'm guessing that because
the email is HTML, it needs a <BR>. Does anybody know how I can send a <BR>
in a string?

Many thanks for your thoughts on this

Ant

"John Richardson" wrote:
try Environment.NewLine?

"Ant" <An*@discussions.microsoft.com> wrote in message
news:2F**********************************@microsof t.com...
Hi,
I'm using the MailMessage object to send an email programmatically via a
console application. It needs to have lines breaks. For example:

string s = "This is the first line + "\n\r" + "and this is the second
line.";

This works fine when written to the console however the MailMessage object
ignores the \ escape key and returns a single lined string.

How can I use carriage returns in a MailMessage?

Many thanks in advance.


Dec 21 '05 #4
Ant
Actually, I inadvertently answered my own question. Because it is treating
the text as HTML, I simply added the break to the string i.e.

"This is the text<BR>This is the next line."

and it wote it to the email with the breaks.
"Ant" wrote:
Hi,

well, I tried both your solutions. "\r\n" gives the same result as "\n\r"
and Enviroment.NewLine, is also treated the same. I'm guessing that because
the email is HTML, it needs a <BR>. Does anybody know how I can send a <BR>
in a string?

Many thanks for your thoughts on this

Ant

"John Richardson" wrote:
try Environment.NewLine?

"Ant" <An*@discussions.microsoft.com> wrote in message
news:2F**********************************@microsof t.com...
Hi,
I'm using the MailMessage object to send an email programmatically via a
console application. It needs to have lines breaks. For example:

string s = "This is the first line + "\n\r" + "and this is the second
line.";

This works fine when written to the console however the MailMessage object
ignores the \ escape key and returns a single lined string.

How can I use carriage returns in a MailMessage?

Many thanks in advance.


Dec 21 '05 #5

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

Similar topics

4
7307
by: Les Juby | last post by:
Can someone please help with a suggestion as to how I can keep the formatting (carriage returns) that the user enters into a memo field and then display that later. I figured I might be able to...
2
2923
by: eagleofjade | last post by:
I am trying to import data from a Word document into an Access table with VBA. The Word document is a form which has various fields. One of the fields is a field for notes. In some cases, this...
2
2314
by: Matt Mercer | last post by:
Hi all, I am having a frustration problem, and I have read about 25 newsgroup postings that do not have a satisfying answer :) The problem appears to be common where carriage returns are lost...
7
11163
by: mattrapoport | last post by:
I have a page with a div on it. The div displays a user comment. When the user logs into this page, their current comment is pulled from a db and displayed in the div. The user can edit the...
0
7106
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6967
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
7137
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,...
1
6846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5442
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.