How to download email attachments using Exchange Web Services Java API

1142720 pts.
Tags:
EWS
Microsoft Exchange
I'm currently writing a Java application to download several emails using Exchange Web Services. I'm using Microsoft's EWS Java API to do this. I'm able to fetch email headers but I'm not able to download the email attachments using the API. Here's a snippet of my code:
FolderId folderId = new FolderId(WellKnownFolderName.Inbox, "mailbox@example.com");
findResults = service.findItems(folderId, view);
for(Item item : findResults.getItems()) {
   if (item.getHasAttachments()) {
      AttachmentCollection attachmentsCol = item.getAttachments();
      System.out.println(attachmentsCol.getCount()); // This is printing zero all the time. My message has one attachment.
      for (int i = 0; i < attachmentsCol.getCount(); i++) {
         FileAttachment attachment = (FileAttachment)attachmentsCol.getPropertyAtIndex(i);
         String name = attachment.getFileName();
         int size = attachment.getContent().length;
      }
   }
}
Can someone help me out?
1

Answer Wiki

Thanks. We'll let you know when a new response is added.
Hi,
I have googled about your problem and found a helpful article for you http://msdn.microsoft.com/en-us/library/office/dd633665(v=exchg.80).aspx  I hope it will help you.

Thanks & Regards
Clark Kent

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: