2010-08-15 119 views
0

我爲系統生成的電子郵件添加了純文本版本,因爲沒有文本版本的電子郵件被視爲垃圾郵件。這裏是我的代碼:html ws文本電子郵件 - 如何在gmail中顯示html版本?

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); 

它的偉大工程,但現在我的問題是,這樣的系統,Gmail郵件顯示備份文本版本,而不是主要的HTML版本!

到目前爲止,我發現電子郵件來自兩個部分組成:

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

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

第一個是較大的,它必須是HTML的版本(正如你看到的,我設置IsBodyHtml到真正)。 任何想法?

回答

1

解決方案是將文本版本添加到Body,並將文本/ html版本添加爲ALternateView

相關問題