C# 使用SMTP 发送邮件时如何邮件内容中显示图片
1、初始化 MailMessage
MailMessage email = new MailMessage();
2、添加附件
email.Attachments.Add(newAttachment("C:\\img\\ewen.gif"));
3、设置附件类型
email.Attachments[0].ContentType.Name= "image/gif" ;
4、设置附件 Id
email.Attachments[0].ContentId = "ewen";
5、设置附件为 inline-内联
email.Attachments[0].ContentDisposition.Inline= true;
6、设置附件的编码格式
email.Attachments[0].TransferEncoding =System.Net.Mime.TransferEncoding.Base64;
7、在HTML邮件正文中用img 标签引用图片,src 设置为 cid:附件Id
stringmailBody = "这里显示图片:<br><img alt='图片' src=cid:ewen>";
8、完成发送邮件。
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:59
阅读量:48
阅读量:42
阅读量:24
阅读量:178