带有<strong> </strong>的ASP.NET MVC System.Net.Mail

时间:2016-10-13 18:40:08

标签: c# system.net.mail

我通过ASP.NET MVC System.Net.Mail发送电子邮件,我的电子邮件正文中有html标记<strong></strong>但是当我发送电子邮件时,文本看起来像<strong>MESSAGE</strong>而不是它是大胆的,我该如何解决这个问题?

这是我的代码:

var message = "<strong>MESSAGE</strong>\n\n";
MailAddress to = new MailAddress(email2@example.com);
MailAddress from = new MailAddress("email@example.com");
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");

1 个答案:

答案 0 :(得分:3)

您需要将IsBodyHtml标记设置为true

email.IsBodyHtml = true;