Aditya Kar
Aditya Kar

Reputation: 546

Using MS Graph API is it possible to just list the email attachments without downloading the its content?

We're using MS Graph API to get the list of emails from an Outlook 365 mailbox. We have a requirement to list the attachments in every email.

When using the List Attachments endpoint of the Graph API, the contentBytes attribute value in the response contains the entire Base64 encoded attachment content. This increases the response size significantly. We have no need to access or store the attachment content.

https://learn.microsoft.com/en-us/graph/api/message-list-attachments?view=graph-rest-1.0&tabs=http#example

Is there a way in MS Graph API to just get the attachment file name(s) and IDs for one or more email messages?

Upvotes: 2

Views: 2897

Answers (1)

Shiva Keshav Varma
Shiva Keshav Varma

Reputation: 3575

Yes, you can use the same /attachments endpoint and get only the id and name of attachment using the $select query parameter.

Simply use the query

https://graph.microsoft.com/v1.0/me/messages/{messageid}/attachments?$select=id,name

Result:

enter image description here

You can always test graph calls in Graph Explore.

Upvotes: 3

Related Questions