.NET C# 发送邮件内容嵌入图片
2012-04-01 23:12 thtfria 阅读(1514) 评论(0) 编辑 收藏 举报邮件内容调用图片格式为:<img src=\"cid:Email001\">
发送邮件的服务端代码为:
SmtpClient 发送邮件的对象 //代码省略
System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
mailMessage.From="发送者邮箱";
mailMessage.To.Add("收件人邮件列表");
mailMessage.CC.Add("抄送人邮件列表");
mailMessage.Subject = subject;
AlternateView htmlBody = AlternateView.CreateAlternateViewFromString(content,null,"text/html");
LinkedResource lrImage = new LinkedResource("a.jpg","image/gif");
lrImage.ContentId = "Email001";
htmlBody.LinkedResources.Add(lrImage);
mailMessage.AlternateViews.Add(htmlBody);
SmtpClient.Send(mailMessage);