1
votes

im trying to delete a FileAttachment within an attached Outlook-Mail-Item in a EmailMessage, but its saying the following error when updating the EmailMessage:

At least one attachment couldn't be deleted.

Heres the code im using:

// eMessageToWork is an attached EmailMessage
// Im saving the attachments from eMessageToWork to disk before i want to remove it from the attached email
Attachment att = eMessageToWork.Attachments[i];
// ... saving attachments to disk ...

// Now remove the attachment from the attached mail
eMessageToWork.Attachments.Remove(att);

// rootMailMessage is the root mail and contains as attachment eMessageToWork
// Here is the problem and the exception is thrown.
rootMailMessage.Update(ConflictResolutionMode.AlwaysOverwrite);

I had more strange errors to resolve since the version changed to 2016. I cant even do it manually by just opening outlook, because the context option "remove" when right-clicking the file-attachment is greyed out.

Is there a problem with my access rights? If yes, next question would be, why im not getting a proper exception message then? :D

Does anyone have clue on major security changes for exchange server 2016, that could be the source for this?

1

1 Answers

0
votes

I have tried run your code, it works fine on my PC.

So the first thing I would suggest you to check is the permissions of the user.

Secondly, if that doesn't resolve the problem for you, I would suggest adding a trace listener to your code and post your EWS request and response so we can track this down a bit further.

Here is an article that should help you with the trace listener:

How to: Trace requests and responses to troubleshoot EWS Managed API applications