关于MailMessage发送邮件
我用下面这段发送邮件的时候提示:
异常详细信息: System.Runtime.InteropServices.COMException: óê?t?T·¨·¢?íμ? SMTP ·t???÷?£′?ê?′í?ó′ú???a 0x80040217?£·t???÷?ìó|?a not available
//=================代码如下=======================================
//创建MailMessage对象
MailMessage mailMsg = new MailMessage();
//设置收件人的邮件地址
mailMsg.To = "****@yahoo.com.cn";
//设置发件人的邮件地址
mailMsg.From = "****@****.com";
//设置邮件主题
mailMsg.Subject = "取回你的密码";
//设置邮件内容
mailMsg.Body ="密码";
//设置正文格式
mailMsg.BodyFormat = MailFormat.Html;
//设置支持服务器验证
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//设置用户名
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "abc");
//设置用户密码
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "123456");
//try
//{
//设置发送邮件服务器
SmtpMail.SmtpServer = "smtp.****.com";
//发送邮件
SmtpMail.Send(mailMsg);