none
Working with attachments in EWS RRS feed

  • Question

  • Hello All,

    I am currently working with attachments using ews. I am able send mail with multiple attachment and also able to download single attachment. Now I have following things needs to be implemented in my application ?

    1. How can I download all attachment of mail ?

    Downloading single attachment I have done; but I would like to download all attachments in zip folder. Is is possible in ews ??

    2. Remove attachment when composing a mail ?

    Lets say, I am writing a new mail and I have added 2 attachments; then I want to remove 1 attachment from it; then how can i do this ? also, how Unremoved attachment will be available in email message ?

    Regards,

    Rohit Pundlik


    Tuesday, January 27, 2015 9:06 AM

All replies

  • Hi Rohit,

    1.) Downloading Attachments:
    You can iterate over the Attachments property using a foreach loop and write it to file. In order to Zip the result, you'll need to either use a compression library or the native .NET functions if you have .NET 4.5 available.

    2.) Removing Attachments:
    Again you use the Attachments property of the EmailMessage object. It has a remove method to get rid of individual unwanted attachments.

    Cheers,
    Fred


    There's no place like 127.0.0.1

    Tuesday, January 27, 2015 9:35 AM
  • Hi Rohit,

    1.) Downloading Attachments:
    You can iterate over the Attachments property using a foreach loop and write it to file. In order to Zip the result, you'll need to either use a compression library or the native .NET functions if you have .NET 4.5 available.

    2.) Removing Attachments:
    Again you use the Attachments property of the EmailMessage object. It has a remove method to get rid of individual unwanted attachments.

    Cheers,
    Fred


    There's no place like 127.0.0.1

    Thats true, But to iterate in attachment collection OR retrieve the attachment collection I need to have EmailMessage.Id for that ? 

    Because while composing email; 'Id' is not generated; then how can I do this ?

    Regards,

    Rohit

    Friday, January 30, 2015 6:58 AM
  • Hi Rohit,

    if you're still composing the email, why do you need to download attachments? You should still be able to get to the source files (otherwise sending them would fail).

    In order to access the attachments in an Email (sent or unsent), you do not need to Id of the Email - you need the EmailMessage object itself. Granted, having the Id makes it simple to bind it, but there are other ways to access it (Searching).

    Anyway, the EmailMessage object has an attachments property. That's where you find the Attachments.

    Cheers,
    Fred


    There's no place like 127.0.0.1

    Friday, January 30, 2015 7:31 AM