Using Azure Logic Apps, automate data loading from email attachments.

Ajith Nagarajan
BI3 Technologies
Published in
5 min readNov 5, 2021
  • Azure Logic apps to read an email, get its attachment
  • Save the attachment into the Azure Storage container blob
  • Send email confirmation once the attachment is uploaded to the Azure container

Extract Email attachment

Let’s assume that we received a CSV file for import in the outlook.com mailbox. To create a workload, we can use a suitable template, or we can start with a blank logic app template, as shown below.

In the app designer, search for Outlook. It returns all matched components for it. Click on the Outlook.com component as a source component.

It opens a list of items in the triggers. We want to generate an action when a new email arrives in the Inbox of outlook.com. Therefore, click on When a new email arrives from the Triggers menu.

You need to sign in to Outlook.com with your credentials.

In the configuration, enter the following details:

  • Folder: Inbox
  • Importance: Any
  • Only with Attachments: Select Yes because we wanted to upload email attachments into the Azure blob container
  • Include attachments: Yes
  • From: Usually, we receive an email from a specific email address such as vendor email id. Therefore, enter the email id in the field
  • Subject filter: We can further filter emails from the Inbox using a specific subject filter. Here, we want to check emails with the subject line — Azure Data Import CSV

Click on +New step. Now, we need to define what action you need to take once a new email arrives.

Click on Outlook.com and navigate to actions, select Get attachment.

In the Get attachment configuration, it requires configuration for Message Id and Attachment Id.

  • Message Id: Click on the Add dynamic content and select Message id as shown below

Attachment Id: Here, we need to map the id of the attachment we want to download. Click on Add dynamic content and select Attachments Attachment id.

It displays For each block for attachments.

Configure Azure Blob Storage destination

Next, click on Add an action. In the next step, we define the target storage location for storing these email attachments. In this demo, my destination storage in an Azure blob container. We already configured the input container for storing these files. Therefore, search for Azure Blob Storage.

To upload a file into the Azure blob, select the Create blob from the actions list.

It automatically lists the azure storage account with the resource group and location. If you want a different storage account, you can enter the details manually as well.

Select your azure storage account and enter a connection name, as shown below.

It asks for the following configuration of creating the blob action item:

  • Folder path: Click on the folder icon and select the container to save the email attachment. Here, we want to save these files into the /input container
  • Blob Name: In this configuration, we specify the blob container file format. For this purpose, I use the dynamic content option — Attachment Name

Click on the blob name text box and click on Add dynamic content and select Attachment Name

  • Blob content: In the blob content, select Attachment Content from the dynamic content.

Let’s execute this azure logic app to validate things are working fine as expected. Until now, we implemented the following logic.

  • When a new email arrives in specified Outlook.com id, and it has a subject — Azure Data Import CSV, the logic app saves its attachment into an azure blob storage container

For demonstration purposes, I created the following CSV file.

Click on Run in the logic apps designer.

Create an email with the subject line that we specified during logic app configuration and send it to the configured email address. Here, you can see the email I sent with the Products.csv file as an attachment.

We received the email in my configured email Inbox.

About Us

Bi3 has been recognized for being one of the fastest-growing companies in Australia. Our team has delivered substantial and complex projects for some of the largest organizations around the globe and we’re quickly building a brand that is well known for superior delivery.

Website : https://bi3technologies.com/

Follow us on,
LinkedIn : https://www.linkedin.com/company/bi3technologies
Instagram :
https://www.instagram.com/bi3technologies/
Twitter :
https://twitter.com/Bi3Technologies

--

--