.NET 使用C#两种发送邮件的方法
来源:互联网 发布:ubuntu 15.10 下载 编辑:程序博客网 时间:2024/05/01 00:06
第一种:
1、配置文件(Web.config) + 少量C#代码
在 configuration 节点下添加
<system.net> <mailSettings> <smtp from="baidu@163.com"> <network host="smtp.163.com" password="baidu" port="25" userName="baidu" defaultCredentials="false"/> </smtp> </mailSettings> </system.net>
/// <summary>
/// 发送邮件/// </summary>private void SendMail(){ System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); message.From = new System.Net.Mail.MailAddress("baidu@163.com");//发送人邮箱地址,与smtp节点中的from值一致 message.To.Add(new System.Net.Mail.MailAddress("taobao@163.com"));//接收人邮箱地址 message.Subject = "hello"; message.Body = "<b>taobao</b>"; message.IsBodyHtml = true; System.Net.Mail.SmtpClient smtpclient = new System.Net.Mail.SmtpClient(); smtpclient.Send(message);}
好,介绍完第一种发送邮件的方法,下面看第二种。
/// <summary>
/// 发送邮件/// </summary>private void SendMail(){ System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); message.From = new System.Net.Mail.MailAddress("baidu@163.com");//发送人邮箱地址,与smtp节点中的from值一致 message.To.Add(new System.Net.Mail.MailAddress("taobao@163.com"));//接收人邮箱地址 message.Subject = "hello"; message.Body = "<b>taobao</b>"; message.IsBodyHtml = true; System.Net.Mail.SmtpClient smtpclient = new System.Net.Mail.SmtpClient("smtp.163.com", 25); smtpclient.Credentials = new System.Net.NetworkCredential("baidu", "baidu");//参数分别是邮箱用户名和密码 smtpclient.Send(message);}
- .NET 使用C#两种发送邮件的方法
- c#发送邮件内嵌图片的两种方法
- Asp.net发送邮件的两种方法
- 使用PHP发送邮件的两种方法
- 使用PHP发送邮件的两种方法
- django 发送邮件的两种方法
- C# 发送邮件的方法
- ASP.NET+C#使用JMail发送邮件
- Testlink发送邮件的两种配置方法
- Testlink发送邮件的两种配置方法
- Testlink发送邮件的两种配置方法
- Java程序发送邮件的两种方法
- Java程序发送邮件的两种方法
- Java程序发送邮件的两种方法
- Java程序发送邮件的两种方法
- Testlink发送邮件的两种配置方法
- 网站发送邮件及群发的两种方法
- TestLink学习三:发送邮件的两种配置方法
- DSO
- 应用程序端口号
- android Activity类的使用
- 解决scott用户登录不了问题
- 在innerHTML的中有script标签该如何运行
- .NET 使用C#两种发送邮件的方法
- TOMCAT路径问题
- 解锁scott用户及设置密码
- PSA
- Tomcat6.0虚拟目录配置
- VSS 连接报错 :The Sourcesafe Web service cannot be accessed at the specified address
- tomcat数据库连接池
- TemplateMethod パターン
- 导航控件