system.net.mail isbodyhtml = true 与两个 AlternateView 的优缺点
这是用例:
我正在制作一个将通过电子邮件发送 HTML 新闻通讯的应用程序。该应用程序还将通过电子邮件发送简讯的纯文本版本作为替代视图。在我看来,使用 system.net.mail 命名空间时有两种方法可以解决此问题。这两种方式的优点/缺点是什么,或者我还缺少另一种方式吗?谢谢。
Dim m As New MailMessage
' One alternate view'
m.IsBodyHtml = True
m.Body = HTMLString
m.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(plaintextstring), Nothing, "text/plain")
' OR two alternate views without specifying the body '
m.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(plaintextstring), Nothing, "text/plain")
m.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(HTMLstring), Nothing, "text/html")
Here is the use case:
I am making an app that will email HTML Newsletters. The app will also email a plain text version of the newsletter as an alternate view. The way I see it there are two ways of going about this when using the system.net.mail namespace. What are the pro/cons of these two ways, or is there a another way that I am missing? Thank you.
Dim m As New MailMessage
' One alternate view'
m.IsBodyHtml = True
m.Body = HTMLString
m.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(plaintextstring), Nothing, "text/plain")
' OR two alternate views without specifying the body '
m.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(plaintextstring), Nothing, "text/plain")
m.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(HTMLstring), Nothing, "text/html")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,这是执行此操作的两种方法,您可能还需要为备用视图设置以下内容,因为如果不这样做,不同客户端之间可能会产生奇怪的副作用。
nope these are the two ways of doing it, you might also want to set the following for the alternate views as there can be weird side effects across different clients if not.