locked
Timeout error when sending email using System.Net.Mail RRS feed

  • Question

  • User206383436 posted

    I am trying to send an email from a web form. The email service in our company is offered by the ISP (using our domain name) so I talked to them to get the correct information about how to contact the host (email server). The code I use to send the email is shown below but I get a timeout exception. Employees in our company use MS Outlook to send/receive email so I double checked the parameters and they are the same the ISP gave me.

    SmtpClient objSmtpClient = new SmtpClient();
    objSmtpClient.Host = "the ISP email server here";
    objSmtpClient.Port = 465;
    objSmtpClient.EnableSsl = true;
    objSmtpClient.Credentials = new System.Net.NetworkCredential("an email account here", "password here");
    objSmtpClient.Send(objMailMessage);

    I have already tried several workarounds I have found searching the Internet without success.
    I will very much appreciate your feedback.

    Respectfully,
    Jorge Maldonado

    Friday, February 7, 2014 11:25 AM

Answers

  • User206383436 posted

    I had tried the timeout setting without success, also I have reviewed a lot of articles and basically they all say about the same. What I did is to use a library from www.afterlogic.com instead of system.net.mail and I could send emails.

    Best regards,
    Jorge Maldonado

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 11, 2014 2:57 PM

All replies

  • User-1454326058 posted

    Hi JORGEMALMRimascttech,

    Thanks for your post!

    Please try to specify the TimeOut time, such as:

    objSmtpClient.Timeout = 20000;

    There is a link may benefit you:

    # Send Mail / Contact Form using ASP.NET and C#

    http://www.codeproject.com/Tips/371417/Send-Mail-Contact-Form-using-ASP-NET-and-Csharp

    Thanks

    Best Regards  

    Sunday, February 9, 2014 9:46 PM
  • User206383436 posted

    I had tried the timeout setting without success, also I have reviewed a lot of articles and basically they all say about the same. What I did is to use a library from www.afterlogic.com instead of system.net.mail and I could send emails.

    Best regards,
    Jorge Maldonado

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 11, 2014 2:57 PM