/// <summary> |
/// 最简单的发送邮件实例 |
/// </summary> |
/// <param name="title">邮件标题</param> |
/// <param name="mailReceive">接收有地址</param> |
/// <param name="content">邮箱内容</param> |
public void MailSend( string title, string mailReceive, string content) |
{ |
//MailAddress:表示电子邮件发件人或收件人的地址 |
MailAddress from = new MailAddress( "yinll25@163.com" ); |
// MailMessage:表示可以使用 System.Net.Mail.SmtpClient 类发送的电子邮件。 |
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(); |
mail.Subject = title; //设置标题 |
mail.To.Add(mailReceive); //接收地址 |
mail.Body = content; //内容 |
mail.From = from; |
|
//SmtpClient:允许应用程序使用简单邮件传输协议 (SMTP) 来发送电子邮件 |
SmtpClient client = new SmtpClient(); |
|
//设置邮箱服务器地址 |
client.Host = "smtp.163.com" ; |
|
//获取或设置用于验证发件人身份的凭据 |
client.Credentials = new System.Net.NetworkCredential( "yinll25" , "yin__15874151521" ); |
|
//正式发送咯 |
client.Send(mail); |
} |