cancel
Showing results for 
Search instead for 
Did you mean: 

Graph API - Outlook -- How to download Binary Files ( Excel Attachments)

spalkar1
Level 3
Hi,
 I have been able to use the Graph API interface to read emails and download -- text, csv attachments.
But I do not know how to download an Excel Attachment ?
 Can you anyone provide samples/ links for the same ?

-Saurabh
1 REPLY 1

ewilson
Staff
Staff
Hi @spalkar1,

​The existing Outlook connector for Graph doesn't include any options for pulling saving attachments from a received email. That's due to a couple issues including the fact that the Web API feature of Blue Prism doesn't support binary data. It's also an oversight on our part because this should have been added to the Download Files asset for Graph. I'll get that updated ASAP.

In the meantime, here's the basic process.
  1. Each received message includes a property called hasAttachments. This is a boolean so true if there are attachments or false otherwise. Be aware that if the sender includes a picture as part of the signature, that picture will also be handled as an attachment.
  2. If you have an email where the hasAttachments flag is set, you want to get the unique ID of the email and then issue an HTTP GET request to /users/[ID]/messages/[Message ID]/attachments. This will return details about all of the attachments. The details of each attachment include information about the content-type of the attachment (ex. image/png).
  3. In some cases, you can find the binary data of the attachment under the property called contentBytes. In other cases, you'll want to get the unique ID of the attachment from its details and then issue another HTTP GET request to /users/[ID]/messages/[Message ID]/attachments/[Attachment ID]/$value
Cheers,
Eric