ASP.NET MVC System.Net.Mail with <strong></strong&g
本文关键字:lt strong gt with MVC NET System Net Mail ASP | 更新日期: 2023-09-27 18:13:02
我通过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");
您需要将IsBodyHtml
标志设置为true
:
email.IsBodyHtml = true;