C#发送内置图片的html格式邮件的代码
2021-06-20 13:06
标签:dia body edr img with 内容 port typename dde
将写内容过程经常用的内容段备份一次,下面的内容是关于C#发送内置图片的html格式邮件的内容,应该对码农们也有用处。
MailMessage m = new MailMessage();
m.Subject = "html email with embedded image coming!";
string htmlBody = "
Picture
";
AlternateView avHtml = AlternateView.CreateAlternateViewFromString
(htmlBody, null, MediaTypeNames.Text.Html);
LinkedResource pic1 = new LinkedResource("pic.jpg", MediaTypeNames.Image.Jpeg);
pic1.ContentId = "Pic1";
avHtml.LinkedResources.Add(pic1);
string textBody = "You must use an e-mail client that supports HTML messages";
AlternateView avText = AlternateView.CreateAlternateViewFromString
(textBody, null, MediaTypeNames.Text.Plain);
m.AlternateViews.Add(avHtml);
m.AlternateViews.Add(avText);
client.Send(m);
C#发送内置图片的html格式邮件的代码
标签:dia body edr img with 内容 port typename dde
原文地址:https://www.cnblogs.com/lpyg/p/10260947.html
上一篇:c#中,字符串前加@是什么意思
下一篇:c#学习总结