SmtpClient: A connection attempt failed because the connected party did not properly respond after a period of time

后端 未结 2 780
日久生厌
日久生厌 2020-12-03 17:01

While working with Email sending in C#.NET in visual studio 2008 i got the below error

A connection attempt failed because the connected party did not

相关标签:
2条回答
  • 2020-12-03 17:27

    This happened to me due to my company security wifi. Once I changed to open wifi, the problem was solved automatically.

    0 讨论(0)
  • 2020-12-03 17:37

    The following code works for me. Your code was giving me errors, I believe it was due to not setting the port to 587.

    http://forums.asp.net/t/1250771.aspx/4/10

    MailMessage mail = new MailMessage();
    mail.To.Add(to);
    mail.From = new MailAddress(from);
    mail.Subject = subject;
    mail.Body = body;
    mail.IsBodyHtml = true;
    SmtpClient smtp = new SmtpClient("smtp.gmail.com",587);
    smtp.EnableSsl = true;
    smtp.UseDefaultCredentials = false;
    smtp.Credentials = new System.Net.NetworkCredential(address, password);
    smtp.Send(mail);
    
    0 讨论(0)
提交回复
热议问题