简体   繁体   中英

ASP.NET MVC System.Net.Mail with <strong></strong>

I am sending emails via ASP.NET MVC System.Net.Mail and my email body has html tag in it <strong></strong> but when I send the email, the text looks like this <strong>MESSAGE</strong> instead of it being bold, how can I fix this?

Here is my code:

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM