Saving attchment as file

-- -- 892 Reputation points


I am using below code to access mail file attachments. I have two questions;

  1. How can I only get unread messages?
  2. How can I save file attachment into a file?



      var inboxMessages = await graphClient

      foreach(Microsoft.Graph.Message message in inboxMessages) {

        if (message.HasAttachments == true) {
          var attachments = await graphClient
            .Messages[$ "{message.Id}"]

          foreach(var attachment in attachments) {
            if (attachment is FileAttachment) {
              FileAttachment fileAttachment = attachment as FileAttachment;

              //Save fileAttachment content to file here

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

1 answer

Sort by: Most helpful
  1. Deva-MSFT 2,256 Reputation points Microsoft Employee
    0 comments No comments