tags:

views:

489

answers:

1

I am trying to send an email with a plain text body and an alternate html body. However, when I snoop the data going over the network the text portion of the email is lost.

Here is a sample of my coding attempts.

private static MailMessage BuildEmail(string plainText, string htmlBody)
{
 // Add the alternate body to the message.
 ContentType HtmlContentType = new ContentType("text/html");
 AlternateView alternate = AlternateView.CreateAlternateViewFromString(htmlBody, HtmlContentType);

 ContentType PlainContentType = new ContentType("text/plain");
 AlternateView PlainView = AlternateView.CreateAlternateViewFromString(plainText, PlainContentType);

 MailMessage mail = new MailMessage(new MailAddress(ToEmail_DEFAULT),
  new MailAddress(FromEmail_DEFAULT));

 mail.Subject = "First plain. Html next";
 mail.AlternateViews.Add(PlainView);
 mail.AlternateViews.Add(alternate);

 return mail;
}


http://www.my914.net/images/work/emailProblem.jpg

+1  A: 

The problem ending up being the network snooping application. Getting the latest version of the application allowed me to see that the data being sent to the SMTP server was correct and contained both my plain text view and the html text view.

David Wilson