locked
(The operation has timed out) when sending email RRS feed

  • Question

  • Hi,

    I am using below code to send email but getting:

    The operation has timed out.

    evertime I try to send an email

    I am hosting with dreamhost.

    What could be the issue please?

    Thanks,

    Jassim

    mail_message = new MailMessage();
    smtp_client = new SmtpClient("mail.mybluefile.com");
    
    mail_message.From = new MailAddress("noreply-employee-request@mybluefile.com", "BlueFile");
    mail_message.To.Add(new MailAddress(Convert.ToString(sql_command.Parameters["param_employee_email"].Value), Convert.ToString(sql_command.Parameters["param_employee_name"].Value)));
    
    email_body = new StringBuilder();
    
    email_body.Append("<i>Please do not reply to this message. Replies to this message are routed to an unmonitored mailbox.</i>");
    email_body.Append("<hr>");
    email_body.Append("<br><br>");
    email_body.Append("My message here......";
    email_body.Append("<br>");
    email_body.Append("Best Regards,");
    email_body.Append("<br>");
    email_body.Append("BlueFile");
    
    mail_message.Subject = cboCategory.Text + " Request is Completed";
    mail_message.IsBodyHtml = true;
    mail_message.Body = email_body.ToString();
    
    smtp_client.Port = 465;
    smtp_client.Credentials = new System.Net.NetworkCredential("noreply-employee-request@mybluefile.com", "xxxxxxxx");
    smtp_client.EnableSsl = true;
    ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
    
    smtp_client.Send(mail_message);
    

    Friday, July 31, 2015 7:52 PM

Answers

  • Hi Jassim,

    This problem occurs when you're not able to connect to the SMTP server, hence the timeout message. There are several possibilities why this problem has occurred:

    • Wrong SMTP address
    • SMTP rejected
    • SMTP server is offline
    • Port setting
    • SSL configuration

    You should try setting the credentials, or the server is down or is not replying at all - these are the errors that might generate this problem. Please ensure that the above points are correct.

    I also tested with your code,  use hotmail instead and change port to 587, the code works fine.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Kristin Xie Friday, August 21, 2015 3:17 AM
    • Marked as answer by Fred Bao Friday, August 21, 2015 3:19 AM
    Monday, August 3, 2015 2:43 AM