CMS*_*CMS 44
只需将MailMessage.BodyFormat属性设置为MailFormat.Html,然后将html文件的内容转储到MailMessage.Body属性:
using (StreamReader reader = File.OpenText(htmlFilePath)) // Path to your
{ // HTML file
MailMessage myMail = new MailMessage();
myMail.From = "from@microsoft.com";
myMail.To = "to@microsoft.com";
myMail.Subject = "HTML Message";
myMail.BodyFormat = MailFormat.Html;
myMail.Body = reader.ReadToEnd(); // Load the content from your file...
//...
}
Run Code Online (Sandbox Code Playgroud)
A-S*_*ani 17
我正在使用System.Net.Mail.MailMessage你的情况,你可以使用:
mail.IsBodyHtml = true;
Run Code Online (Sandbox Code Playgroud)
System.Web.Mail.MailMessage已废弃但如果使用它:mail.BodyFormat有效.
| 归档时间: |
|
| 查看次数: |
68378 次 |
| 最近记录: |