温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

C#发送邮件并将图片插入邮件内容

发布时间:2020-06-30 02:16:02 来源:网络 阅读:1682 作者:温馨梦痕 栏目:编程语言

 

邮件内容的字符串

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 = "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++;            }


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI