4

I am invoking the following code:

public static void SendMessage(string sender, string recipient,string subject,string body)
{
    var message = new MailMessage(sender, recipient, subject, body);
    _smtpClient.Send(message);
}

There are line breaks a.k.a. Environment.NewLine in the body of the message, but when I open the message in Outlook, they are not there. What am I missing?

A-K
  • 16,162
  • 5
  • 51
  • 70

1 Answers1

7

Do you see the "Extra line breaks in this message were removed." message underneath the sender's address in message window?

If so, click the "Extra line breaks" message and select "Restore line breaks."

rrhartjr
  • 2,004
  • 2
  • 14
  • 21
  • that worked, thanks! However, I do not want Outlook remove line breaks which I deliberately put where I want them? Is there any way I can get rid of this annoying behavior? – A-K Mar 21 '11 at 20:10
  • 1
    See this link: http://stackoverflow.com/questions/247546/outlook-autocleaning-my-line-breaks-and-screwing-up-my-email-format, which involves prefixing lines with two spaces to "fool" Outlook. Or use HTML formatted email, which Outlook will not try to format at all. – rrhartjr Mar 21 '11 at 20:11
  • 1
    If you want to remove this behaviour on your copy of Outlook, On the Tools menu, click Options. On the Preferences tab, click the E-mail Options button. Click to clear the Remove extra line breaks in plain text messages check box. Click OK two times. (See http://support.microsoft.com/kb/287816) – sgmoore Mar 21 '11 at 20:30