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