【问题标题】:html ws text emails - how to show html version in gmail?html ws 文本电子邮件 - 如何在 gmail 中显示 html 版本?
【发布时间】:2010-08-15 18:50:21
【问题描述】:

我在系统生成的电子邮件中添加了纯文本版本,因为没有文本版本的电子邮件被视为垃圾邮件。这是我的代码:

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 设置为 true)。 有什么想法吗?

【问题讨论】:

    标签: .net email gmail html-email


    【解决方案1】:

    解决办法是把文本版本放到 Body 中,并添加 text/html 版本作为 ALternateView

    【讨论】:

      猜你喜欢
      • 2016-11-05
      • 2011-07-08
      • 2014-10-22
      • 2023-04-01
      • 2020-01-10
      • 1970-01-01
      • 2011-10-30
      • 1970-01-01
      相关资源
      最近更新 更多