Search code examples
exchange-serverexchangewebservicesews-managed-api

EWS Edit Attachments in a Forward Email


I'm working on an application that let users manage their emails from a website.

The user can reply to an email as well as forward a an email etc....

My problem is that I want to give the users the ability to remove attachments from

a forward instance of an existing email before sending it.

ResponseMessage response;
response = OriginalEmail.CreateForward(); // create response
ForwardEmail = response.Save(WellKnownFolderName.Drafts);

The ForwardEmail doesn't contain any attachment in the attachments collection.

However when using

 ResponseMessage response;
 response = this.Email.CreateForward(); // create response
 this.Response = response.Save(WellKnownFolderName.Drafts);
 this.Response.ToRecipients.Add("me", "me@gmail.com");
 this.Response.Send();

I'm getting the attachments in the destination email.

How can I edit the attachments before forwarding?

Thanks in advance


Solution

  • After you call the Save method

    ForwardEmail = response.Save(WellKnownFolderName.Drafts);
    

    You should then do Load using a propertySet the specifies you want the attachments returned eg

    PropertySet psPropset = new PropertySet(BasePropertySet.FirstClassProperties);
    ForwardEmail.Load(psPropset);
    

    That should then populate the Attachment Collection.

    Cheers Glen