• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4272
  • Last Modified:

newline email body C#

I am trying to send an email using the default email client ( in C# 2005 )  in the following manner:

private void SendEmail ()
    string emailMessage;                // Email message to be sent
    string body;                              // Email message body
    string subject;                          // Email subject
    subject = Subject + "-" + ck.GetSiteCode2 ();
    body         = "Name:  "+ Environment.NewLine;
    body        += "Phone number:  " + Environment.NewLine;
    emailMessage = string.Format ( @"mailto:{0}?subject={1}&body={2}", MailTo, subject, body );
    Process.Start ( emailMessage );

It opens the Outlook email client with all the correct information except that body is not formatted properly.  It is showing like this:

Name:  Phone number:

and should be like this:

Phone Number:

What am I doing wrong?
  • 3
  • 2
1 Solution
Try this:

Convert.ToChar(13).ToString() + Convert.ToChar(10).ToString();
jumanac14Author Commented:
Same result as before... any other suggestions?
Try using "%0A" instead of the carriage return/line feeds.
jumanac14Author Commented:
It worked! Great expert advice...! would you mind explaining why it works like that?
You're sending a URL, and the process will strip out any special characters.  To send these characters, you need to use hexadecimal:  line feed is 10 in ASCII, which is %0A in hex.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now