By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,625 Members | 1,283 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,625 IT Pros & Developers. It's quick & easy.

How do I create line breaks in a string to be passed to email app?

P: n/a
Hi,

I am trying to start my email app (in this case Eudora) with a
programatically generated email. However, Eudora does not seem to recognize
any of the ways I have tried to create line breaks.

I have tried "\n", "\r\n", and using the StringBuilder AppendLine() method
like this:

StringBuilder body = new StringBuilder(1024);

// AppendLine doesn't work
body.AppendLine("Thank you for registering!");

// Neither does this
body.Append(System.Environment.NewLine);
body.Append("Support Forums");
body.AppendLine();
body.Append("Please be sure that you have the latest version, ");

Process process = new Process();
process.StartInfo.FileName = "mailto:";
process.StartInfo.FileName += tbEmail.Text;
process.StartInfo.FileName += "?subject=GaugeGlow License Key";
process.StartInfo.FileName += "&b*********************@comcast.net";
process.StartInfo.FileName += "&body=";
process.StartInfo.FileName += body;

process.Start();

yet, when the email opens in the application, there are no line breaks at all.

Stick

Sep 13 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Stick,

You might want to try URL encoding the body part of the url. It might
work then.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Stick" <St***@discussions.microsoft.comwrote in message
news:69**********************************@microsof t.com...
Hi,

I am trying to start my email app (in this case Eudora) with a
programatically generated email. However, Eudora does not seem to
recognize
any of the ways I have tried to create line breaks.

I have tried "\n", "\r\n", and using the StringBuilder AppendLine() method
like this:

StringBuilder body = new StringBuilder(1024);

// AppendLine doesn't work
body.AppendLine("Thank you for registering!");

// Neither does this
body.Append(System.Environment.NewLine);
body.Append("Support Forums");
body.AppendLine();
body.Append("Please be sure that you have the latest version, ");

Process process = new Process();
process.StartInfo.FileName = "mailto:";
process.StartInfo.FileName += tbEmail.Text;
process.StartInfo.FileName += "?subject=GaugeGlow License Key";
process.StartInfo.FileName += "&b*********************@comcast.net";
process.StartInfo.FileName += "&body=";
process.StartInfo.FileName += body;

process.Start();

yet, when the email opens in the application, there are no line breaks at
all.

Stick

Sep 13 '06 #2

P: n/a
Stick,

I am not sure in this case, however that mostly the <brdoes help in some
case (if your text is used in the mail as html) would I try that in your
situation first.

Cor

"Stick" <St***@discussions.microsoft.comschreef in bericht
news:69**********************************@microsof t.com...
Hi,

I am trying to start my email app (in this case Eudora) with a
programatically generated email. However, Eudora does not seem to
recognize
any of the ways I have tried to create line breaks.

I have tried "\n", "\r\n", and using the StringBuilder AppendLine() method
like this:

StringBuilder body = new StringBuilder(1024);

// AppendLine doesn't work
body.AppendLine("Thank you for registering!");

// Neither does this
body.Append(System.Environment.NewLine);
body.Append("Support Forums");
body.AppendLine();
body.Append("Please be sure that you have the latest version, ");

Process process = new Process();
process.StartInfo.FileName = "mailto:";
process.StartInfo.FileName += tbEmail.Text;
process.StartInfo.FileName += "?subject=GaugeGlow License Key";
process.StartInfo.FileName += "&b*********************@comcast.net";
process.StartInfo.FileName += "&body=";
process.StartInfo.FileName += body;

process.Start();

yet, when the email opens in the application, there are no line breaks at
all.

Stick

Sep 13 '06 #3

P: n/a
I found this from the C# specification.

9.3.1 Line terminators

31 Line terminators divide the characters of a C# source file into lines.

32 new-line::

33 Carriage return character (U+000D)

34 Line feed character (U+000A)

35 Carriage return character (U+000D) followed by line feed character
(U+000A)

36 Next line character (U+0085)

37 Line separator character (U+2028)

38 Paragraph separator character (U+2029)

39 For compatibility with source code editing tools that add end-of-file
markers, and to enable a source file to be

40 viewed as a sequence of properly terminated lines, the following
transformations are applied, in order, to every

41 source file in a C# program:

42 . If the last character of the source file is a Control-Z character
(U+001A), this character is deleted.

43 . A carriage-return character (U+000D) is added to the end of the source
file if that source file is non-empty

44 and if the last character of the source file is not a carriage return
(U+000D), a line feed (U+000A), a line

45 separator (U+2028), or a paragraph separator (U+2029).

You can download it from:
http://msdn.microsoft.com/netframewo...r/default.aspx

if you wish. Good luck

chanmm
"Stick" <St***@discussions.microsoft.comwrote in message
news:69**********************************@microsof t.com...
Hi,

I am trying to start my email app (in this case Eudora) with a
programatically generated email. However, Eudora does not seem to
recognize
any of the ways I have tried to create line breaks.

I have tried "\n", "\r\n", and using the StringBuilder AppendLine() method
like this:

StringBuilder body = new StringBuilder(1024);

// AppendLine doesn't work
body.AppendLine("Thank you for registering!");

// Neither does this
body.Append(System.Environment.NewLine);
body.Append("Support Forums");
body.AppendLine();
body.Append("Please be sure that you have the latest version, ");

Process process = new Process();
process.StartInfo.FileName = "mailto:";
process.StartInfo.FileName += tbEmail.Text;
process.StartInfo.FileName += "?subject=GaugeGlow License Key";
process.StartInfo.FileName += "&b*********************@comcast.net";
process.StartInfo.FileName += "&body=";
process.StartInfo.FileName += body;

process.Start();

yet, when the email opens in the application, there are no line breaks at
all.

Stick

Sep 13 '06 #4

P: n/a
Cor,

"Cor Ligthert [MVP]" wrote:
Stick,

I am not sure in this case, however that mostly the <brdoes help in some
case (if your text is used in the mail as html) would I try that in your
situation first.
Yes, my first thought too, but didn't work.

Stick

Sep 13 '06 #5

P: n/a
Nicholas,

"Nicholas Paldino [.NET/C# MVP]" wrote:
You might want to try URL encoding the body part of the url. It might
work then.
Hmmmm. I did an MSDN search, but don't see that it is possible to set this
format with the class I'm using, and I'm not too sure how to do it another
way. But thanks for the idea.

Sep 13 '06 #6

P: n/a
Stick,

Use the static UrlEncode method on the HttpUtility class in the
System.Web namespace. You will have to add a reference to System.Web.dll to
do this as well.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Stick" <St***@discussions.microsoft.comwrote in message
news:73**********************************@microsof t.com...
Nicholas,

"Nicholas Paldino [.NET/C# MVP]" wrote:
> You might want to try URL encoding the body part of the url. It
might
work then.

Hmmmm. I did an MSDN search, but don't see that it is possible to set
this
format with the class I'm using, and I'm not too sure how to do it another
way. But thanks for the idea.

Sep 13 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.