如果客户端不支持html,我希望将电子邮件显示为html,以shud显示邮件为text / plain。我已经编写了代码,但不确定是否有人可以检查如何在这里检查多内容和多个mimetype。
mailMessage.IsBodyHtml = true;
mailMessage.From = new MailAddress(from);
foreach (string adress in to)
{
mailMessage.To.Add(adress);
}
string path = string.Empty;
var htmlView = AlternateView.CreateAlternateViewFromString(mailMessage.Body, null, "text/html");
答案 0 :(得分:0)
ContentType mimeType = new System.Net.Mime.ContentType("text/html");
// Add the alternate body to the message.
AlternateView alternate = AlternateView.CreateAlternateViewFromString(mailMessage.Body, mimeType);
mailMessage.AlternateViews.Add(alternate);