将写内容过程经常用的内容段备份一次,下面的内容是关于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);