这是什么MailMessage.IsBodyHtml办? [英] What does MailMessage.IsBodyHtml do?

查看:122
本文介绍了这是什么MailMessage.IsBodyHtml办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我测试发送通过C#的一些邮件,但我不能告诉什么效果 IsBodyHtml 设置为有。无论这个值,无论我在送我的身体显示了text / plain的内容类型,和我的HTML出现在我的电子邮件客户端(Gmail的)标签和所有。那是什么标志实际上应该怎么办?

I'm testing sending out some emails via C#, but I can't tell what effect setting IsBodyHtml to true has. Regardless of the value, whatever I send in my Body shows up with a content type of "text/plain", and my HTML shows up tags and all in my email client (gmail). What is that flag actually supposed to do?

注:我可以通过创建发送HTML电子邮件就好了 AlternateView 以为text / html的内容类型,我只是想了解如何定身应该工作

NOTE: I can send an HTML email just fine by creating an AlternateView with a content type of "text/html", I just want to understand how setting the body is supposed to work.

推荐答案

我只是纠结于这个相同的问题。我最好的解决办法是避免设置 MailMessage 对象的车身属性在所有。而不是仅仅添加两个 AlternateView S,第一个纯文本,然后一个HTML。请务必先添加纯文本版本,因为MIME标准说:

I just wrestled with this same problem. My best solution was to avoid setting the Body property of the MailMessage object at all. Instead just add two AlternateViews, first a plain text then an HTML. Make sure to add the plain text version first because the MIME standard says that:

该格式由他们是如何忠实是原来的,用最少的忠实第一个和最忠实的排在最后。

The formats are ordered by how faithful they are to the original, with the least faithful first and the most faithful last.

这意味着,你把纯文本版第一,所以客户应该使用的HTML版本,如果可能的。

That means, that you put the plain text version first, so the clients should use the HTML version if possible.

这篇关于这是什么MailMessage.IsBodyHtml办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆