question

Leigh-7291 avatar image
0 Votes"
Leigh-7291 asked AtulThorat-MSFT answered

Graph API 'https://graph.microsoft.com/v1.0/me/messages/*****/attachments' is no longer returning the attached filename for '.msg' files:

I am using the the following Graph API URL to retrieve the filename(s) attached to an email:

https://graph.microsoft.com/v1.0/me/messages/*/attachments

however, it is no longer returning the attached filename(s) for '.msg' files:

{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('')/messages('')/attachments",
"value": [
{
"@odata.type": "#microsoft.graph.itemAttachment",
"id": "*",
"lastModifiedDateTime": "2021-08-13T11:21:29Z",
"name": "Original Email",
"contentType": null,
"size": 45795,
"isInline": false
}
]
}

Where as it is for other file types:

{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('')/messages('')/attachments",
"value": [
{
"@odata.type": "#microsoft.graph.fileAttachment",
"@odata.mediaContentType": "application/octet-stream",
"id": "",
"lastModifiedDateTime": "2021-08-13T11:14:07Z",
"name": "Original Email.mht",
"contentType": "application/octet-stream",
"size": 54693,
"isInline": false,
"contentId": null,
"contentLocation": null,
"contentBytes": "
"
}
]
}

NB: sensitive info has been redacted (*).

I can see that the @odata.type is returned differently:

@odata.type": "#microsoft.graph.itemAttachment
@odata.type": "#microsoft.graph.fileAttachment

I'm not sure why this is, the email is attached in the same way: In both of the above cases, I sent myself an email, saved it to my local filesystem, created another email, attached the previously saved file and sent myself the new email with the saved email attached.

Is there a way to return the filename for '.msg' files?

microsoft-graph-mail
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AtulThorat-MSFT avatar image
0 Votes"
AtulThorat-MSFT answered

Hi @leigh-7291,

Hope you are doing well.

I have used below Graph API endpoint

GET https://graph.microsoft.com/v1.0/me/messages/{ {id}}/attachments

GET https://graph.microsoft.com/v1.0/me/messages/AAMkADRlNzY0M2NmLTRmMGItNDUyYS1hYThhLThlNzE5NTVmMDZiOQBGAAAAAABR21-6ABv8TagD21M49AjtBwBgYaQ-pmuUR4IFYCzhSxPIAAAAAAEJAABgYaQ-pmuUR4IFYCzhSxPIAAAffvPzAAA=/attachments

So we are getting below response.

 {
     "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('6ab5cc33-a9d6-40b1-a84f-993e06d170f3')/messages('AAMkADRlNzY0M2NmLTRmMGItNDUyYS1hYThhLThlNzE5NTVmMDZiOQBGAAAAAABR21-6ABv8TagD21M49AjtBwBgYaQ-pmuUR4IFYCzhSxPIAAAAAAEJAABgYaQ-pmuUR4IFYCzhSxPIAAAffvPzAAA%3D')/attachments",
     "value": [
         {
             "@odata.type": "#microsoft.graph.referenceAttachment",
             "id": "AAMkADRlNzY0M2NmLTRmMGItNDUyYS1hYThhLThlNzE5NTVmMDZiOQBGAAAAAABR21-6ABv8TagD21M49AjtBwBgYaQ-pmuUR4IFYCzhSxPIAAAAAAEJAABgYaQ-pmuUR4IFYCzhSxPIAAAffvPzAAABEgAQAOWC7WnKwNxJnPEivSxIh6c=",
             "lastModifiedDateTime": "2022-02-23T15:41:44Z",
             "name": "Batch Processing.docx",
             "contentType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
             "size": 1258,
             "isInline": true
         }
     ]
 }


177298-filename.png

So here we can see "name" property is available in response which represents filename.

Hope this helps.

If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".



filename.png (167.2 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.