graphClient attachment contentbytes

Jay Guru 1 Reputation point
2021-03-31T14:10:46.61+00:00

Hi,

I am trying to read documents attached to an email and store them in database.

I am able to get the fileAttachment into a FileAttachment variable using the below code.

                                                        var attachmentRequest = graphClient.Users[User.ID].Messages[message.Id].Attachments[attachment.Id].Request().GetAsync();
                                                        var fileAttachment = attachmentRequest.Result;

I want to retrieve the contents of the attachment and store it, but ContentBytes is not available for use. Only ContentType is available.

thanks in advance.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,723 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Patrick Pater 1 Reputation point
    2021-05-12T09:09:48.397+00:00

    Use:

    var fileAttachment = attachmentRequest.Result as Microsoft.Graph.FileAttachment;

    0 comments No comments