Sunday, January 26, 2025

OIC - Extract Microsoft 365 Outlook Email Attachments and upload them to OCI Object storage

Use Case:

A client has a requirement to automate the processing of email attachments received in their Microsoft 365 Outlook inbox. Currently, they manually download the attachments from emails and upload them to Oracle Cloud Infrastructure (OCI) Object Storage for archival and further processing. This process is time-consuming and prone to errors.

The client needs a solution where the attachments are automatically extracted from specific emails (based on criteria like sender, subject, or date) and uploaded to a designated OCI Object Storage bucket. This ensures seamless and timely processing of files while reducing manual effort and improving efficiency.

Design steps:

We need to follow these steps to implement the solution:

  1. Configure the Mailbox: Set up the mailbox and create a connection in OIC using the Microsoft Office 365 Outlook adapter.

  2. Set Up Object Storage Connection: Establish a connection to OCI Object Storage in OIC.
  3. Design a Scheduled Integration: Create a scheduled integration in OIC and implement the following steps:
    1. Fetch emails from the configured mailbox.
    2. Read the email messages.
    3. Extract the attachments from the emails.
    4. Upload the extracted attachments to OCI Object Storage.
Integration flow:



Steps involved in integration flow:

Step1: Fetch the email messages from the configured mailbox
Select method: Get Messages

Step2: Loop over the fetched Email messages and check for email messages having attachments


Step3: Fetch the email attachments using the method: "Get an Attachment Collection" of the MS outlook adapter.


Map the message id template parameter to fetch the attachments of the email message.


Step4: Loop over the fetched attachments and upload each attachment to object storage bucket using the PUT operation of the Rest API.

Step5: Map the input content file and object name. Decode to stream reference using decodeBase64ToReference() function. Bucket name, namespace name can be passed from a lookup. 



Configure Microsoft office 365 outlook adapter connection in OIC:




Create a connection to the Object Storage

Either use the REST endpoint using the Object Storage Service API — https://docs.oracle.com/en-us/iaas/api/#/en/objectstorage/20160918/ 

you can follow my blog

https://soalicious.blogspot.com/2022/08/oic-how-to-use-oci-object-storage-from.html

or configure your Oracle Integration instance using the steps in this link — https://docs.oracle.com/en/cloud/paas/application-integration/integrations-user/add-actions-app-driven-orchestration-integration.html#GUID-822226B0-B8EB-42E0-B053-8D844D2F45DB to access Object Storage using OCI Object Storage Action.


For mailbox setup follow this below Medium post: It has involved two steps:
  1. Create a microsoft office 365 outlook account with custom domain
  2. Register the application in Azure to create client Id and client secret.

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...