none
EWS send mail error "The request failed. operation timeout" RRS feed

  • Question

  • If I add an attachment to more than 1.2M, the prompt operation is timed out; however, the use of outlook to send mail is not limited to the size of the attachment

    thanks!

    c# coding:

    	static void Main(string[] args)
            {
                try
                {
                    string username = args[0];
                    string password = args[1];
                    string domain = args[2];
                    string frommail = args[3];
                    string subject = args[4];
                    string body = args[5];
                    string[] tos = args[6].Split(';');
                    string[] files = args[7].Split(';');
    		
                    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
                    
                    service.Credentials = new WebCredentials(username, password, domain);
                    service.TraceEnabled = true;
                    service.TraceFlags = TraceFlags.All;
                    service.AutodiscoverUrl(frommail, RedirectionUrlValidationCallback);
                    EmailMessage email = new EmailMessage(service);
                    
                    foreach (string t in tos)
                    {
                        email.ToRecipients.Add(t);
                    }
                    email.Subject = subject;
                    email.Body = new MessageBody(body);
                    foreach (string s in files)
                    {
                        email.Attachments.AddFileAttachment(s);
                    }
                    
                    email.Send();
                }
                catch (Exception ex)
                {
                    System.IO.File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "\\Error.log", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ")+ex.Message+"\r\n");
                }
            }
    	private static bool RedirectionUrlValidationCallback(string redirectionUrl)
            {
                bool result = false;
                Uri redirectionUri = new Uri(redirectionUrl);
                if (redirectionUri.Scheme == "https")
                {
                    result = true;
                }
                return result;
            }


    dog

    Sunday, July 12, 2015 11:41 PM

Answers

  • The default timeout is 90 seconds so if your upload doesn't complete in this time (due to very poor network connectivity) then you would get a timeout error. I would suggest you increase the timeout may 5 minutes to start with

    service.timeout = 300000;

    Cheers
    Glen

    • Marked as answer by pcodg Monday, July 13, 2015 1:52 PM
    Monday, July 13, 2015 12:49 AM