Graph API Retrieving Nested Mail Attachments Not Available
Graph API Retrieving Nested Mail Attachments Not Available
We are using the Graph API to connect to an account using Java. We are able to make calls to retrieve user details, mail details, headers and attachments, etc… One of our use cases require us to retrieve information related to nested attached emails (e.g. an email in the account has an attached email. This email has an attached email and also some attached files). By using the Graph API, we are able to retrieve information related to the email including attachments https://graph.microsoft.com/v1.0/me/messages/{messageid}/?$expand=attachments. From what’s returned, we are able to retrieve the ID belong to the attached email and use that to retrieve informationhttps://graph.microsoft.com/v1.0/me/messages/{messageid}/attachments/{attachment_id}?$expand=microsoft.graph.itemattachment/item. The problem is, we cannot find a way to retrieve the attachments belong to this.
This is just something additional that we came across. When you make the following call https://graph.microsoft.com/v1.0/me/messages/{messageid}/attachments/{attachmentid}?$expand=microsoft.graph.itemattachment/microsoft.graph.itemattachment/item, you get back an error response saying “Only one level expand is supported”. Not too sure if this is relevant, but just extra information.
Also, when you make the following call https://graph.microsoft.com/v1.0/me/messages/{message_id}?$expand=Attachments($expand=microsoft.graph.itemattachment/item($expand=microsoft.graph.event/attachments)), you get back an error response saying "The result of parsing $expand was at least 3 items deep, but the maximum allowed is 2".
In this thread, it seems that this functionality wasn’t available in 2015 and it was stated that it was going to be put on the backlog https://stackoverflow.com/questions/32749496/how-to-retrieve-itemattachment-contents-from-office-365-rest-api. Again, not too sure if this is relevant, but it may give a little more context.
This is a critical part of one of our applications and functionality that we need, and would expect to be possible.

This feature is now available in public beta. You can export the contents of an item attachment as MIME and process it offline to find nested attachments. Documentation is available at https://docs.microsoft.com/en-us/graph/api/attachment-get?view=graph-rest-beta#get-the-raw-contents-of-a-file-or-item-attachment
1 comment
-
Craig Wampler commented
I would say that having to parse all the data yourself from MIME is not the same as having this as a MS Graph feature. Seems like I should be able to do GET ...../messages/<id1>/attachment/<id2>/attachment/<id3> ....