Search code examples
microsoft-graph-apimicrosoft-graph-mail

Getting the attachments of an attached Message in Microsoft Graph


I'm trying to retrieve emails using Microsoft Graph(and the Microsoft Graph SDK) and i'm running into the following problem : when the email has another Outlook message attached to it and that message also has attachments, i'm unable to get them.

I'm able to retrieve the attached message with the following query, but I can't do a second expand on attachments as I'm already doing one to get the OutllokItem(message)

/v1.0/users/<UserName>/messages/<MessageId>/attachments/<AttachmentID>?$expand=microsoft.graph.itemattachment/item

Is this possible at all ? Thanks in advance.


Solution

  • For anyone looking for a solution, there's a feature currently available on beta only that allows you to get the whole message in Mime text format.

    To get an attachment

    /beta/users/<UserName>/messages/<MessageId>/attachments/<AttachmentID>/$value
    

    To get the full initial message :

    /beta/users/<UserName>/messages/<MessageId>/$value
    

    See https://learn.microsoft.com/en-us/graph/api/attachment-get?view=graph-rest-beta&tabs=cs for details