views:

57

answers:

1

I added plain text version to system generated emails, because email without text version is considered as spam. Here is my code:

MailMessage mm = new MailMessage(
new MailAddress(from, msg.FromName), new MailAddress(msg.ToEmail, msg.ToName)); 
mm.Subject = msg.Subject;
mm.Body = msg.Body;
mm.IsBodyHtml = 1;
mm.Priority = MailPriority.Normal;
ContentType plainContentType = new ContentType("text/plain");
AlternateView plainTextView = AlternateView.CreateAlternateViewFromString(msg.BodyTxt, plainContentType);
mm.AlternateViews.Add(plainTextView);

It works great, but now my problem is that such systems as gmail show back up text version, not main html version!

So far i discovered that email consist from 2 parts:

Content-Type: ***text/plain***; charset=utf-8
Content-Transfer-Encoding: base64

and

Content-Type: text/plain
Content-Transfer-Encoding: base64

First one is larger and it must be the HTML version (as you see, I set IsBodyHtml to true). Any ideas?

A: 

Solution was to put text version to Body, and add text/html version as ALternateView

Sergey Osypchuk