Search code examples
graphoutlookmicrosoft-graph-apioutlook-addin

Why outlook msg file does not have any contentBytes? using graph microsoft api


I have a small script to get all my outlook mails and its attachments. And its working fine.

I can get all the mail and its attachments. However there's particular email that i have a problem.

That email has two attachments "sample.msg" and "sample.pdf". By using this endpoint https://graph.microsoft.com/v1.0/me/messages/{message-id}/attachments i can get it.

But why is it the sample.msg has no contentBytes?

enter image description here

Is there a way i can get the contentBytes for sample.msg? or there is another endpoint for that particular attachment type?

Please help me to understand this problem.


Solution

  • The @odata.type itemAttachment indicates that the main message. To get the properties of the item attached to a message, you need to make a separate call and expand item relationship

    GET /v1.0/me/messages/{message_id}/attachments/{attachment_id}?$expand=microsoft.graph.itemattachment/item
    

    Or you can get MIME raw content of the attachment

    GET /v1.0/me/messages/{message_id}/attachments/{attachment_id}/$value