2016-10-13 117 views
0

我通過ASP.NET MVC System.Net.Mail發送電子郵件,我的電子郵件正文中有html標籤<strong></strong>但是當我發送電子郵件時,文本看起來像這<strong>MESSAGE</strong>而不是大膽的,我該如何解決這個問題?ASP.NET MVC System.Net.Mail與<strong></strong>

這裏是我的代碼:

var message = "<strong>MESSAGE</strong>\n\n"; 
MailAddress to = new MailAddress([email protected]); 
MailAddress from = new MailAddress("[email protected]"); 
MailMessage email = new MailMessage(from, to); 
email.Subject = "Subject Line"; 
email.Body = message; 
email.BodyEncoding = System.Text.Encoding.UTF8; 
SmtpClient client = new SmtpClient("mail.example.com"); 
+0

當你擁有的東西如何構建到.NET作品的問題,檢查[相關文檔](https://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage(v = vs.110).aspx)。 – mason

回答

3

您需要設置IsBodyHtml標誌true

email.IsBodyHtml = true;