发送邮件的代码
来源:互联网 发布:赣州富云软件 编辑:程序博客网 时间:2024/06/05 20:50
public void SendEmailMethod()
{
try
{
//创建邮箱实例对象
MailMessage mail = new MailMessage();
string fromaddrss=this.txtFromMail.Text;
string toaddress=this.txtToMail.Text;
//创建发送人地址
MailAddress from = new MailAddress(fromaddrss, "在邮件列表显示的中文名称", System.Text.Encoding.GetEncoding("GB2312"));
mail.From = from;
//创建收件人地址
MailAddress to = new MailAddress(toaddress);
mail.To.Add(to);
//设置邮件的标题
mail.Subject = "中文标题";
//设置邮件的内容
mail.Body = this.txtMailContext.Text;
//设置邮件的格式,可以包含HTML标签和超链接
mail.IsBodyHtml = true;
//设置邮件的格式
mail.BodyEncoding = System.Text.Encoding.GetEncoding("GB2312");
//设置邮箱的发送级别
mail.Priority = MailPriority.Normal;
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
//邮件发送服务器
SmtpClient client = new SmtpClient();
client.Host = this.txtSMTP.Text;
//设置用于stmp事务端口
client.Port = 25;
client.UseDefaultCredentials = false;
//邮箱地址用户和密码
client.Credentials = new System.Net.NetworkCredential("1826546303", "tlj19931112");//通过网络发送
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Send(mail);
}
catch (Exception ex)
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(),"","alert('"+ex.Message+"')",true);
throw;
}
}
{
try
{
//创建邮箱实例对象
MailMessage mail = new MailMessage();
string fromaddrss=this.txtFromMail.Text;
string toaddress=this.txtToMail.Text;
//创建发送人地址
MailAddress from = new MailAddress(fromaddrss, "在邮件列表显示的中文名称", System.Text.Encoding.GetEncoding("GB2312"));
mail.From = from;
//创建收件人地址
MailAddress to = new MailAddress(toaddress);
mail.To.Add(to);
//设置邮件的标题
mail.Subject = "中文标题";
//设置邮件的内容
mail.Body = this.txtMailContext.Text;
//设置邮件的格式,可以包含HTML标签和超链接
mail.IsBodyHtml = true;
//设置邮件的格式
mail.BodyEncoding = System.Text.Encoding.GetEncoding("GB2312");
//设置邮箱的发送级别
mail.Priority = MailPriority.Normal;
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
//邮件发送服务器
SmtpClient client = new SmtpClient();
client.Host = this.txtSMTP.Text;
//设置用于stmp事务端口
client.Port = 25;
client.UseDefaultCredentials = false;
//邮箱地址用户和密码
client.Credentials = new System.Net.NetworkCredential("1826546303", "tlj19931112");//通过网络发送
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Send(mail);
}
catch (Exception ex)
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(),"","alert('"+ex.Message+"')",true);
throw;
}
}
0 0
- 发送邮件的代码~
- 发送邮件的代码
- 发送邮件的代码
- 简单的发送邮件代码
- ASP发送邮件的代码
- 一段发送邮件的代码
- 简单的发送邮件代码
- 发送邮件的plsql代码
- 发送邮件的代码示例
- java的邮件发送代码
- 利用jmail发送邮件的代码
- ASP.Net 2.0 发送邮件的代码
- ASP.Net 2.0 发送邮件的代码
- ASP.Net 2.0 发送邮件的代码
- 最简单的邮件发送代码FreePoster
- C#邮件发送的系统部分代码
- ASP.Net 2.0 发送邮件的代码
- JMail组件发送邮件的Asp代码
- lucene学习--全文检索lucene介绍
- Web_文件的上传-FileUpload
- IOS开发之细节知识点汇总
- Android Studio 导入包时报 Duplicate files copied in APK 时的解决办法
- LXC(Linux containers)常用命令介绍
- 发送邮件的代码
- 程序员对内存的理解
- 关于Infinite Script的相关说明
- JSTL 核心标签库使用
- 使用Jenkins搭建iOS开发的CI服务器
- activity finish
- C语言基础课程 第一课 Linux环境配置小实战httpserver
- 通过js来设置cookie和读取cookie,实现登陆时记住密码的功能
- 各个stmp的地址