惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
U
Unit 42
aimingoo的专栏
aimingoo的专栏
Engineering at Meta
Engineering at Meta
博客园 - 聂微东
小众软件
小众软件
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Announcements
Recent Announcements
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
Stack Overflow Blog
Stack Overflow Blog
博客园_首页
M
MIT News - Artificial intelligence
博客园 - 司徒正美
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
IT之家
IT之家
C
Check Point Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tailwind CSS Blog
D
Docker
Microsoft Security Blog
Microsoft Security Blog
Google DeepMind News
Google DeepMind News

博客园 - 思然

XML查找节点 - 思然 - 博客园 动态生成rdlc 报表(原创) 图片处理 - 思然 - 博客园 数据绑定及其他 - 思然 - 博客园 图片上传及网络相册功能 SQL Server 2005 Express 使用心得 - 思然 附加进程调试和存储过程调试 (转)DIV CSS布局教程:应用ul、li实现表格形式 用户控件的使用经验 缓存之缓存文件依赖及编程方式设置输出缓存过期 防刷新多次提交 枚举的应用 添加div符号注意符号问题 Datalist调用本地文件绑定图片 用户控件-TreeView的用法 关于table控件的一个疑难问题(涉及循环) 关于javascript调用webservices的中文参数乱码的问题 服务器端和客户端清除TextBox控件的值 获取母版页的控件的方法
邮件带图片附件 - 思然 - 博客园
思然 · 2009-05-11 · via 博客园 - 思然

   var m = new MailMessage();

            m.From = new MailAddress("xx");

            m.To.Add(new MailAddress("xx"));

            m.Attachments.Add(new Attachment(@"E:\Downloads\2.jpg"));

            m.Attachments[0].ContentId = "MyPic";

            m.Attachments[0].ContentDisposition.Inline = true;

            m.Attachments[0].NameEncoding = m.SubjectEncoding = m.BodyEncoding = Encoding.UTF8;

           //添加多个附件

     m.Attachments.Add(new Attachment(@"E:\Downloads\dd.xls"));

            m.Attachments[0].ContentId = "MyPics";

            m.Attachments[0].ContentDisposition.Inline = true;

            m.Attachments[0].NameEncoding = m.SubjectEncoding = m.BodyEncoding = Encoding.UTF8;

            m.Subject = "测试";

            m.IsBodyHtml = true;

            m.Body = string.Format(@"<img src=""{0}""/><a href=""{0}"" target=""_blank"">点击新窗口</a>", "cid:" + m.Attachments[0].ContentId);

            var s = new SmtpClient();

            s.EnableSsl = true;

            s.Port = 587;

            s.Host = "smtp.gmail.com";

            s.UseDefaultCredentials = false;

            s.Credentials = new System.Net.NetworkCredential("xx", "xx");

            s.Send(m);