Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

EWS send mail error "The request failed. operation timeout"

$
0
0

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


Viewing all articles
Browse latest Browse all 7132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>