Thursday, February 20, 2025

OIC - How to Retrieve Email Attachments Using Microsoft Graph API: Automating Payment File Processing

Retrieving Email Attachments Using Microsoft Graph API: Automating Payment File Storage in Object Storage

Use Case:
A finance team needs to automate the extraction of payment files from vendor emails in Outlook and securely store them in an object storage solution (e.g., AWS S3, Azure Blob Storage, or Oracle Object Storage). Using Microsoft Graph API, they can programmatically fetch email attachments and upload them to object storage for secure access, processing, and archival.

HighLevel steps:

  1. Create a rest connection using Microsoft Graph APIs.
  2. Get Email unread Messages filtering on Subject.
  3. If no message with attachment found, throw a fault.
  4. For each message, 
    1. check if it has the attachment.
    2. Get list of attachments
    3. For each attachment,
      1. Upload file to Object storage for further processing.
Graph APIs used:

Connection URL: https://graph.microsoft.com/v1.0
Scope: https://graph.microsoft.com/.default
Get messages: /users/{userPrincipalName}/messages
List attachments: /users/{userPrincipalName}/mailFolders/{mailFolderId}/messages/{messageId}/attachments
Upload to object storage: /n/{namespacename}/b/{bucketname}/o/{objectname}

Detailed steps with screenshots:

Create rest connection:



Get Email  unread Messages for a matching subject.




Mapping:



If no message with attachment found:


For each message check if it has attachment



Get list of attachments:





For each attachment, upload content to Object storage




Reference:



No comments:

Post a Comment

Featured Post

OIC - How to Retrieve Email Attachments Using Microsoft Graph API: Automating Payment File Processing

Retrieving Email Attachments Using Microsoft Graph API: Automating Payment File Storage in Object Storage Use Case: A finance team needs t...