![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
using System.Net.Mail;
/// <summary>
/// 发送邮件
/// </summary>
/// <param name="toname">收件人名称</param>
/// <param name="toemail">收件人邮件地址</param>
/// <param name="smtpclient">伺服器</param>
/// <param name="fromname">发件人名称</param>
/// <param name="fromemail">发件人邮件地址</param>
/// <param name="password">发件人邮箱密码</param>
/// <param name="subject">邮件标题</param>
/// <param name="body">邮件主体</param>
/// <returns></returns>
public bool SendEmailForGetpass(string toname, string toemail, string smtpclient, string fromname, string fromemail, string password, string subject, string body)
{
try
{
MailAddress from = new MailAddress(fromemail, fromname);
MailAddress to = new MailAddress(toemail, toname);
MailMessage message = new MailMessage(from, to);
message.Subject = subject;
message.Body = body;
message.Priority = MailPriority.High;
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient(smtpclient);//伺服器,如"smtp.163.com"
client.Credentials = new System.Net.NetworkCredential(fromemail, password);
client.Send(message);
return true;
}
catch (Exception e)
{
return false;
}
}
调用:SendEmailForGetpass("收件人名称", "xx@xx.com", "smtp.163.com", "发件人名称", "xx@xx.com","xxxx","标题","主体");
posted @
2009-08-17 10:04
Hayden Han
阅读(
220)
评论()
编辑
收藏
举报