如何在ASP.NET中发送嵌入图片的邮件
来源:互联网 发布:数据分析类网站 编辑:程序博客网 时间:2024/06/11 07:03
如何在ASP.NET中发送嵌入图片的邮件
using System.Net.Mail;using System.Net.Mime; MailMessage mail = new MailMessage(); //set the addresses mail.From = new MailAddress("xx@xxx.com"); mail.To.Add("xx@xxx.com"); //set the content mail.Subject = "Test";//first we create the Plain Text part AlternateView plainView = AlternateView.CreateAlternateViewFromString("This is my text , viewable by those clients that don't support html", null, "text/plain"); string htmlView1 = "This is my text , viewable by those clients that don't support html"; //then we create the Html part //to embed images, we need to use the prefix 'cid' in the img src value //the cid value will map to the Content-Id of a Linked resource. //thus <img src='cid:logo'> will map to a LinkedResource with a ContentId of 'companylogo' AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlView1 + "<a href = "" ><img src="cid:logo" /></a>", null, System.Net.Mime.MediaTypeNames.Text.Html); //create the LinkedResource (embedded image) string path = Server.MapPath(@"Images/logo.jpg"); // LinkedResource logo = new LinkedResource(path); LinkedResource logo = new LinkedResource(path, "image/jpeg"); logo.ContentId = "logo"; //add the LinkedResource to the appropriate view htmlView.LinkedResources.Add(logo); //add the views mail.AlternateViews.Add(plainView); mail.AlternateViews.Add(htmlView); mail.IsBodyHtml = true; //send the message SmtpClient smtp = new SmtpClient();//"127.0.0.1"); //specify the mail server address smtp.Send(mail);
- 如何在ASP.NET中发送嵌入图片的邮件
- 如何在ASP.NET中发送嵌入图片的邮件
- .net中 发送邮件内容嵌入图片
- 如何在 ASP.NET Core 中发送邮件
- Asp.net 中如何发送邮件
- 在asp.net 2.0中发送邮件
- 在Asp.Net中使用SmtpMail发送邮件的方法
- 在asp.net中发送带有smtp验证的邮件
- 在Asp.Net中使用SmtpMail发送邮件的方法
- 在Asp.Net中发送邮件的常用方法:
- 在Asp.Net中使用SmtpMail发送邮件的方法
- 在Asp.Net中使用SmtpMail发送邮件的方法
- 在ASP.NET中使用SMTPMail发送邮件的方法
- .NET C# 发送邮件内容嵌入图片
- 发送邮件嵌入图片
- asp.net中邮件的发送
- ASP.NET中发送邮件
- asp.net中发送邮件
- Apache httpd 远程拒绝服务
- ARM存储系统管理
- UNIX 设置 JAVA 环境变量
- SQL server和C#,VB.net中Round方法的差异
- taobao数据平台官方博客
- 如何在ASP.NET中发送嵌入图片的邮件
- 网页右下角弹窗代码
- 正则表达式
- NSBundle束使用
- SQL Bulk-copy from Excel
- Windows XP64位系统与语言包下载
- rup:<servername>: RPC: Program not registered in RHEL6.1
- window7 支持一键是用TBCompressor压缩JS和CSS文件
- com组件调用代码示例