2
votes

When I open email message in the office365 web browser page, there is an option to DOWNLOAD contents of the attached to this email itemAttachment ( another message attached to the current one using Microsoft Outlook ) - *.eml file, (contentType: RFC-822).

enter image description here

However, when I'm trying to get the contents of this itemAttachment through Graph API (same operation), the contentBytes response property is not present.

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#users('bbbbb')/messages('fffff')/attachments",
    "value": [{
            "@odata.type": "#microsoft.graph.itemAttachment",
            "id": "gggg",
            "lastModifiedDateTime": "2017-02-13T16:29:45Z",
            "name": "The Daily Build - Compiling your C code to .NET",
            "contentType": "message/rfc822",
            "size": 99129,
            "isInline": false
        }
    ]
}

Any ideas how to get contents of attached outlook message though Graph API ( contentType=itemAttachment )? The fileAttachment contentType is working fine, I can grab the contents from the contentBytes property of the Graph API response. The following API endpoints are considered:

https://graph.microsoft.com/beta/me/messages/{id}/attachments

https://graph.microsoft.com/beta/me/messages/{id}/attachments/{attachmentId}

https://graph.microsoft.com/beta/me/messages/{id}/attachments/{attachmentId}?$expand=#microsoft.graph.itemAttachment/item

neither of the above returns contents of the attached Item.

1
The support to download itemAttachment content is not currently available. We are evaluating it now, and I shall post an update when I have concrete outcome.Sriram Dhanasekaran-MSFT
@SriramDhanasekaran-MSFT any updates on that? is it possible to retrieve content of the itemAttachment now?Semen Shekhovtsov
Have you tried my answer?RiccardoGDev
yep, you are right @RiccardoGDev , the functionality is still in the development, it's available in Beta (or Preview), but I can't use beta nor preview for the live application. Waiting for the stable release.Semen Shekhovtsov

1 Answers

1
votes

It's in beta and there isn't a documentation, but you can get MIME content with Microsoft Graph API:

GET https://graph.microsoft.com/beta/me/messages/{id}/$value

or

GET https://graph.microsoft.com/beta/users/{id | userPrincipalName}/messages/{id}/$value

Attachments:

GET https://graph.microsoft.com/beta/users/{id}/messages/{id}/attachments/{id}/$value

With the response you can create a file with .eml extension.

Edit:

Now it's officially in preview: https://docs.microsoft.com/en-us/graph/outlook-get-mime-message