我检查了其他问题,我能够解决代码中的一些错误,但smtp.Credentials = nc;
,其中nc是我的网络凭据,抛出异常,请求操作在MFE代理上中止,SMTP服务器不可用。
请,任何帮助将不胜感激。下面是我的代码:
MailMessage msg = new MailMessage();
msg.From = new MailAddress("fromemail");
msg.To.Add("toemail");
msg.Subject = "Contact Us";
msg.Body = cname.Text + "sent me this message" + cmessage.Text + "with this email, " + email.Text;
msg.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
smtp.EnableSsl = false;
smtp.UseDefaultCredentials = false;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
NetworkCredential nc = new NetworkCredential();
nc.UserName = "fromemail";
nc.Password = "fromemailpwd";
smtp.Credentials = nc;
smtp.Port = 587;
smtp.Send(msg);
sPanel.Visible = true;
lblSuccess.Text = "Success! Thanks for contacting us, we will get back to you soon.";
我将smtp.Credentials = nc
更改为smtp.Credentials = new NetworkCredentials("fromemail", "fromemailpwd");
现在,正是这一行smtp.Send(msg)
抛出异常。
答案 0 :(得分:0)
我无法收到您看到的相同错误消息,但请查看以下答案:Request action aborted on MFE proxy, SMTP server is not available
但是,我知道Gmail需要EnableSSL = True