服务器认证发送邮件

参数说明
Subject:邮件标题
ToAddress:目标邮箱
FromAddress:发送人邮箱
Body:邮件内容
public static void SendMail(String Subject,String ToAddress,String FromAddress,String Body)
{
MailMessage mail = new MailMessage();
mail.To = ToAddress;
mail.From = FromAddress;
mail.Subject = Subject;
mail.Body = Body;
//以下内容为服务器认证语句
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
//用户名
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "UserID");
//邮箱密码
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "Password");
//写入smtp服务器名字
SmtpMail.SmtpServer = "smtp.163.com";
SmtpMail.Send( mail );
}

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页