标签:邮件内插入图片
邮件内容的字符串
StringBuilder Mbody = new StringBuilder(); Mbody.AppendLine("尊敬的领导:"); Mbody.AppendLine("</br>"); Mbody.AppendLine("<p> 您好!</p>"); Mbody.AppendLine("<p>" + mail.MailBoby + "</p>"); int id = 0; foreach (Models.ChartInfoModel item in mail.ChartList) { Mbody.AppendLine("" + "<a href=" + "‘http://10.18.100.77‘><img alt=‘图片‘ src=cid:" + id + "></a>"); Mbody.AppendLine(" <hr />"); id++; } /////////////////////////////////// int j = 0; foreach (Models.ChartInfoModel item in mail.ChartList) { string filePath = Path.Combine(item.ChartPath, item.ChartTitle + ".png"); message.Attachments.Add(new Attachment(filePath)); //设置附件类型 message.Attachments[j].ContentType.Name = "image/png"; //设置附件 Id message.Attachments[j].ContentId = j.ToString(); //设置附件为 inline-内联 message.Attachments[j].ContentDisposition.Inline = true; //设置附件的编码格式 message.Attachments[j].TransferEncoding = System.Net.Mime.TransferEncoding.Base64; j++; }
本文出自 “温馨梦痕” 博客,请务必保留此出处http://317057112.blog.51cto.com/1361376/1964248
标签:邮件内插入图片
原文地址:http://317057112.blog.51cto.com/1361376/1964248