1

retrieving email message expanding attachments doesn't retrieve referenceattachments (that we upload using upload & share from onedrive) If an email contains only reference attachments the list would return empty

GET /users/{id | userPrincipalName}/messages/{id}/attachments 

I tried following request

GET /users/{id | userPrincipalName}/messages/{id}?$expand=attachments

The above request gets all the attachments however reference attachments are not included in the result.

user2250152
  • 14,658
  • 4
  • 33
  • 57

1 Answers1

0

Try using below URL

GET https://graph.microsoft.com/v1.0/me/messages/{id}/?$expand=microsoft.graph.itemattachment/item

See the docs for more info - https://learn.microsoft.com/en-us/graph/api/attachment-get?view=graph-rest-1.0&tabs=http#example-4-expand-and-get-the-properties-of-an-item-attached-to-a-message-including-any-attachment-to-the-item

vicky kumar
  • 563
  • 3
  • 11
  • it will also not work as we do this when we know the attachment id, tried this and resulted into this "code": "BadRequest", "message": "Parsing OData Select and Expand failed: Encountered invalid type cast. 'microsoft.graph.itemAttachment' is not assignable from 'microsoft.graph.message'." – noumanmalik56 Nov 23 '22 at 08:58
  • the problem is this: Let's say I email a user by attaching a file (upload to onedrive & share) this kind of attachment is know as 'reference attachment'. So when I request to get the message along with attachments, message is retrieved but it does not contain the attachments – noumanmalik56 Nov 23 '22 at 08:59
  • however if I attach a file by using "browse from computer" this kind of attachment is know as fileattachment, So when I request to get the message along with attachments, it will have that attachment listed as well – noumanmalik56 Nov 23 '22 at 09:01
  • I hope the above comments will help you in understanding the problem – noumanmalik56 Nov 23 '22 at 09:02