we send emails with attachments by the ews-service with the follwing code...
EmailMessage message = new EmailMessage(ExchangeServiceController);
EmailAddress sender = new EmailAddress
{
MailboxType = MailboxType.Mailbox,
Address = senderAdress
};
message.From = sender;
message.ToRecipients.AddRange(email.SendTo.GetEmailAdressRange());
message.Subject = email.Subject;
message.Body = new MessageBody(BodyType.HTML, emailText);
string[] fileEntries = SignatureController.GetSignatureImagesFiles();
int i = 0;
foreach (string fileName in fileEntries.Where(f => f.Contains("image")))
{
FileInfo info = new FileInfo(fileName);
message.Attachments.AddFileAttachment(info.Name, fileName);
message.Attachments[i].IsInline = true;
message.Attachments[i].ContentId = info.Name;
i++;
}
foreach (string filename in GetAttachmentsAsFilePathList())
{
message.Attachments.AddFileAttachment(filename);
}
var mailbox = new Mailbox(sender.Address);
var folderIdDrafts = new FolderId(WellKnownFolderName.Drafts, mailbox);
var folderIdSent = new FolderId(WellKnownFolderName.SentItems, mailbox);
// save email at draft to get the mime-content
message.Save(folderIdDrafts);
message.Load(new PropertySet(ItemSchema.MimeContent));
email.EmlContent = message.MimeContent;
if (template.SaveMessageOnSend)
{
message.SendAndSaveCopy(folderIdSent);
}
else
{
message.Send();
}
The email saved in draft. After this we get sometimes an follwoing error...
Type: Microsoft.Exchange.WebServices.Data.ServiceResponseException Source: Microsoft.Exchange.WebServices Message: The operation can't be performed because the item is out of date. Reload the item and try again. HResult: -2146233088 (0x80131500) InnerException: null HashedSignature: 49E2BF981546C920B6A4BC0B27476A40 StackTrace: bei Microsoft.Exchange.WebServices.Data.ServiceResponse.InternalThrowIfNecessary() bei Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute() bei Microsoft.Exchange.WebServices.Data.ExchangeService.SendItem(Item item, FolderId savedCopyDestinationFolderId) bei Microsoft.Exchange.WebServices.Data.EmailMessage.InternalSend(FolderId parentFolderId, MessageDisposition messageDisposition)
It happens often with attachment over 6 MB.
The timeout is over 1 minute and the error becomes before this time.
The maxsize is over 10 MB
When i take this email at outlook and send it from the draft it works fine.
Have anybody an idea to solve this problem?
best regards steve