Tuesday, September 8, 2015

SMTP Timeout error–Resolution.

 

at System.Net.Mail.SmtpClient.Send(MailMessage message)

 

public static bool SendLongProcessEmail(string smtpserver, MailMessage newEmail, SmtpClient client)
        {
            Log logmsg = new Log();
            bool mailSent = false;
            try
            {
             
                try
                {

                    client.Host = smtpserver;
                    client.ServicePoint.MaxIdleTime = 0;
                    client.ServicePoint.ConnectionLimit = 1;
                    client.Timeout = 10000000;
                    client.Send(newEmail);
                    mailSent = true;

                }
                catch (Exception)
                {
                    client.Send(newEmail);
                    mailSent = true;
                }
            }
            catch (Exception ex)
            {
                logmsg.HandleException(ex.StackTrace, ex.Message, "SendLongProcessEmail Method");
                return false;
            }
            return mailSent;
        }

Technorati Tags: ,,,,

No comments:

Post a Comment