I was just tweaking some code that sends out email. I noticed in Gmail that the plain text version of the email was being shown even though it was a multipart message with both plain text and HTML alternatives provided.
MailMessage msg = new MailMessage();
…
System.Net.Mail.AlternateView htmlView;
System.Net.Mail.AlternateView plainView;
htmlView = AlternateView.CreateAlternateViewFromString(
htmlBody,
new ContentType("text/html"));
plainView = AlternateView.CreateAlternateViewFromString(
plainBody,
new ContentType("text/plain"));
msg.AlternateViews.Add(htmlView);
msg.AlternateViews.Add(plainView);
The fix was simple: add the plain text view to the message first. Yup, that’s all it took:
msg.AlternateViews.Add(plainView);
msg.AlternateViews.Add(htmlView);