question

JayGuru-0347 avatar image
0 Votes"
JayGuru-0347 asked saldana-msft edited

graphClient attachment contentbytes

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-sdkmicrosoft-graph-mail
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

adding right tags/teams to assist

0 Votes 0 ·

1 Answer

PatrickPater-8940 avatar image
0 Votes"
PatrickPater-8940 answered

Use:

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.