Hi There,
I'm trying to send mails with attachments. So I sampled pieces of code and find a solution that works fine for me. Unless the attached file is larger than ca. 100 kb.
I'm find some issues concerning timeout and buffersize, but nothing seems related to my problem. On the other hand, I can access the same Exchange-Server over OWA. Sending large Attachments there, is no problem.
Are there any settings in config files or something else, I have to consider?
Using: Exchange Server 2007 SP3, Framework 4.0, EWS Managed API 2.0
At this AddFileAttachement-Line, I get a timeout-error:
message.Attachments.AddFileAttachment("Test.pdf", "c:\\temp\\test.pdf");
Microsoft.Exchange.WebServices.Data.ServiceRequestException : The request failed. The operation has timed out
Here is my Code-snippet:
ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack; ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1); service.Credentials = new WebCredentials("domain\\user", "xyz"); service.Url = new Uri("https://exchangeServer/EWS/Exchange.asmx"); //service.Timeout = 300000; EmailMessage message = new EmailMessage(service); message.ToRecipients.Add("test@domain.com"); message.Subject = "Subject1"; //message.SubjectEncoding = System.Text.Encoding.UTF8; //message.IsBodyHtml = true; message.Body = "test mailbody hello"; //message.BodyEncoding = System.Text.Encoding.UTF8; message.Attachments.AddFileAttachment("Test.pdf", "c:\\temp\\test.pdf"); message.SendAndSaveCopy();
Thanks a lot, Rolf