C#发送邮件并将图片插入邮件内容-创新互联
邮件内容的字符串
StringBuilder Mbody = new StringBuilder(); Mbody.AppendLine("尊敬的领导:"); Mbody.AppendLine(""); Mbody.AppendLine("您好!
"); Mbody.AppendLine("" + mail.MailBoby + "
"); int id = 0; foreach (Models.ChartInfoModel item in mail.ChartList) { Mbody.AppendLine("" + ""); Mbody.AppendLine("
"); 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 = "p_w_picpath/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++; }
创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。
当前标题:C#发送邮件并将图片插入邮件内容-创新互联
文章网址:http://myzitong.com/article/dipede.html