I'm working with the Microsoft Graph API to retrieve message details from Outlook, where I found something odd with the property "hasAttachments".
Typically, the "hasAttachments"
is set to true :
when a message has one or more attachment that is not embedded within the email body
example: Graph API response for a message with non-inline attachment
is set to false in the following two scenarios:
when a message has no attachments
example: Graph API response for a message with no attachments
when a message has one or more attachments and all of its attachments are embedded within the email body known as inline attachment.
example: Graph API response for a message with only inline attachment
There is a property called "isInline" which is set to true if a attachment is inline.
However, The response I'm getting from Graph API seems not as expected.
I encountered a scenario for a message containing an attachment that is not an inline attachment but in the Graph API response both the properties "hasAttachment" and "isInline" were false.
usually if a message has a non-inline attachment the "hasattachment" property will be true but it some of my cases it is set to be false. I have attached the copy of my response in a link below
{
"@odata.etag" : "W/\"CQAAABYAAABEIDZQDkY9Q11HVLaaS/ZVAAEWzqBC\"",
"id": "AAMkADk40TYXNzhjLWE5yzgtNGE5N..."
"hasAttachments": false,
"attachments": [
{
"@odata.type": "#microsoft.graph.fileAttachment",
"@odata.mediaContentType": "application/x-microsoft-rpmsg-message",
"id": "AAMkADk40TYXNzhjLWE5yzgtNGE5NS1hYTd1LT1iZELuw="
"lastModifiedDateTime": "2023-06-22T09:57:48z",
"name": "message_v2.rpmsg",
"contentType": "application/x-microsoft-rpmsg-message",
"size": 118679,
"islnline": false,
"contentld": "21672D7F295E8B4D9e9C6CBD4E7EIBCB@1NDPRDØ1.PROD.OUTLOOK.COM",
"contentLocation": null,
"contentBytes": "qne533e9362efp6d/124Y7fJOK/QgvBg....."
The query I used in Graph explorer:
https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages?$select=hasAttachments&$expand=attachments
I would appreciate any guidance on what I might be missing or if there's something I'm doing wrong. Thank you in advance for your help!
That attachment is listed as an application/x-microsoft-rpmsg-message
which (if you had the "raw" e-mail in its orignal MIME format instead of MS Graph's JSON representation) would be an "Alternative View" of the body of this MIME e-mail - which is why it isn't considered an "attachment" by the MS Graph.