1

Do we know how to fetch attachments of the attached email using Microsoft Graph API ? I have one requirement where I need to read such emails.

I have followed the below link by Microsoft but I can only ready body and not it's attachment https://learn.microsoft.com/en-us/graph/outlook-get-mime-message

pixelbyaj
  • 1,178
  • 1
  • 9
  • 22
  • Have you tried the [next steps in the post/ guide](https://learn.microsoft.com/en-us/graph/outlook-get-mime-message#next-steps) you attached in the question which links [Get attachment](https://learn.microsoft.com/en-us/graph/api/attachment-get?view=graph-rest-1.0&tabs=http#get-the-raw-contents-of-a-file-or-item-attachment) for getting attachment on resources including messages? – Danstan Aug 24 '21 at 08:08
  • "You can append the path segment /$value to get the raw contents of a file or item attachment" from the [documentation](https://learn.microsoft.com/en-us/graph/api/attachment-get?view=graph-rest-1.0&tabs=http#get-the-raw-contents-of-a-file-or-item-attachment) – Neel Shah Aug 24 '21 at 11:15
  • hi pixelbyaj can u share the code snippet for the items attachments – Ram Ki Sep 15 '21 at 12:05
  • i have tried and connected using msal/azure ad and connected graphapi.now the part is to save the attachments from the inbox to a local drive! – Ram Ki Sep 15 '21 at 12:06

1 Answers1

0

Try with this:

            byte[] file = null!;
            Attachment? att;
            try
            {
                file = ((FileAttachment)att).ContentBytes;
            }
            catch (Exception)
            {
                
            }
sergiokml
  • 41
  • 6