出现的错误提示是:
邮件无法发送到 SMTP 服务器。传输错误代码为 0x80040217。服务器响应为 not available
代码如下:(用户名和密码都是正确,能登陆邮箱的)
public delegate string mail(string email, string content); public string sendMail(string email, string content)
{ System.Web.Mail.MailMessage myMail = new System.Web.Mail.MailMessage();
myMail.From = "[email protected]";
myMail.To = email;
myMail.Subject = "MailTest";
myMail.Body = content;
myMail.BodyFormat = MailFormat.Html;
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", " 25");
myMail.Fields.Add ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "[email protected]");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "*****");
SmtpMail.SmtpServer = "smtp.163.com";
//SmtpMail.SmtpServer = "221.130.189.148"; //your smtp server here
SmtpMail.Send(myMail);
return "成功";
} public class MyState
{
public string email;
public string content;
public object previousState;
public mail asyncMail;
} [System.Web.Services.WebMethod]
public IAsyncResult BeginSend(string email, string content, AsyncCallback cb, object s)
{
mail stub = new mail(sendMail);
MyState ms = new MyState();
ms.previousState = s;
ms.asyncMail = stub;
return stub.BeginInvoke(email, content, cb, s);
}
[System .Web .Services .WebMethod ]
public string EndSend(IAsyncResult call)
{
MyState ms = (MyState)call.AsyncState;
return ms.asyncMail.EndInvoke(call);
}
邮件无法发送到 SMTP 服务器。传输错误代码为 0x80040217。服务器响应为 not available
代码如下:(用户名和密码都是正确,能登陆邮箱的)
public delegate string mail(string email, string content); public string sendMail(string email, string content)
{ System.Web.Mail.MailMessage myMail = new System.Web.Mail.MailMessage();
myMail.From = "[email protected]";
myMail.To = email;
myMail.Subject = "MailTest";
myMail.Body = content;
myMail.BodyFormat = MailFormat.Html;
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", " 25");
myMail.Fields.Add ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "[email protected]");
myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "*****");
SmtpMail.SmtpServer = "smtp.163.com";
//SmtpMail.SmtpServer = "221.130.189.148"; //your smtp server here
SmtpMail.Send(myMail);
return "成功";
} public class MyState
{
public string email;
public string content;
public object previousState;
public mail asyncMail;
} [System.Web.Services.WebMethod]
public IAsyncResult BeginSend(string email, string content, AsyncCallback cb, object s)
{
mail stub = new mail(sendMail);
MyState ms = new MyState();
ms.previousState = s;
ms.asyncMail = stub;
return stub.BeginInvoke(email, content, cb, s);
}
[System .Web .Services .WebMethod ]
public string EndSend(IAsyncResult call)
{
MyState ms = (MyState)call.AsyncState;
return ms.asyncMail.EndInvoke(call);
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货