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 设置为 true)。 有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案是将文本版本放入Body,并将text/html版本添加为ALternateView
Solution was to put text version to Body, and add text/html version as ALternateView