jumanac14
asked on
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}&b ody={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:
Name:
Phone Number:
What am I doing wrong?
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}&b
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:
Name:
Phone Number:
What am I doing wrong?
ASKER
Same result as before... any other suggestions?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
Convert.ToChar(13).ToStrin