Download [top] Attachment Using Microsoft Graph Api (2026)

Item Attachment: A Microsoft 365 item, like another email, a contact, or a calendar event, attached to the message.

In your code, you would then decode the "contentBytes" string to reconstruct the original file. Option B: Downloading the Raw Stream (Recommended)

Using the Microsoft Graph .NET SDK, the process is streamlined. Here is a basic example of how to fetch the content stream of an attachment: download attachment using microsoft graph api

Before writing code, it is important to understand that Microsoft Graph categorizes attachments into three main types:

Mail.ReadBasic: Allows the app to read basic properties of messages and attachments. Mail.ReadWrite: Allows the app to read and modify mail. Item Attachment: A Microsoft 365 item, like another

GET https://microsoft.com{user-id}/messages/{message-id}/attachments

This method is preferred for performance as it avoids the overhead of base64 encoding and decoding. Implementation Example (C# SDK) Here is a basic example of how to

GET https://microsoft.com{user-id}/messages/{message-id}/attachments/{attachment-id}/$value

To download an attachment, you first need the unique ID of the message it belongs to and the ID of the attachment itself. You can list all attachments for a specific message using the following GET request: