4
我在C#中使用MailMessage发送HTML电子邮件。我正在使用的代码如下C#MailMessage显示HTML标记的AlternateViews
MailMessage msg = new MailMessage();
AlternateView htmlView = AlternateView.CreateAlternateViewFromString("<B>Test Message</B>", null, "text/html");
msg.AlternateViews.Add(htmlView);
我使用备用视图,因为我需要附加文件并将图像嵌入到电子邮件正文中。当我发送电子邮件到我的Gmail帐户时,我看到收件箱中显示的HTML标签。点击消息查看实际的电子邮件摆脱标签。如何确保标签不显示在收件箱中?
谢谢
我解决了这个问题。我张贴的解决方案作为一个答案我自己的问题,以帮助其他人谁可能会遇到同样的问题
我的代码已经
MailMessage msg = new MailMessage();
msg.Body = "<B>Test Message</B>";
AlternateView htmlView = AlternateView.CreateAlternateViewFromString("<B>Test Message</B>", null, "text/html");
msg.AlternateViews.Add(htmlView);
所需代码的第二行,因为我同时指定被删除一个身体和一个替代的看法造成了问题。
我有msg.IsBodyHtml = true设置,但不帮助 – newidforu 2011-06-08 18:11:00