How to save PDF email attachments to OneDrive for Business using Power Automate

You can use Power Automate to automatically move your email attachments to a folder in OneDrive for Business. In this post I’ll show you how to move PDF (or any other file type) attachments to a OneDrive for Business folder.

This is the flow that we will build:

This is the flow that we will build

1. Start by creating an automated cloud flow:

Select automated cloud flow

2. Give your flow a name then select the flow’s trigger as When a new email arrives (V3):

Set flow a name then select the flow's trigger

3. Set the following two properties of the When a new email arrives (V3) trigger:

When a new email arrives (V3) trigger
Propertydescription
Include AttachmentsShould the response of the trigger include the attachments content.
Only with AttachmentsIf set to true (Yes), only emails with an attachment will be retrieved. Emails without any attachments will be skipped. If set to false (No), all emails will be retrieved.

4. Add an Apply to each loop (2) and set Attachments as the output (3) as shown below. The loop will save each attachment to a OneDrive folder of our choice:

Apply to each loop

5. Add a Condition to check the attachment’s filename (4). We want to check if the attachment name ends with ‘pdf’. If the attachment name ends with ‘pdf’ we want to save it to our OneDrive folder. Change the condition to save other file types.

Image of the flow that we will build

6. Add a OneDrive for Business Create File action (5), then select a OneDrive folder to save the attachments to. In the example below I am saving the attachments to a folder called Attachments:

OneDrive Create file action - select folder
Click on the image above to view a larger screenshot

7. Finally select the attachment’s filename and file content Dynamic content:

OneDrive Create file action
Click on the image above to view a larger screenshot

Saving different File Types

The flow Condition can be changed to support any file type or even multiple different file types, for example:

The flow Condition changed to support  multiple different file types.

Example Runtime output

The example runtime output below shows that the Apply to each loop ran seven times. This means that seven files were sent as file attachments in the email but only one attachment (number seven) was a PDF document. Attachment number seven was the only file saved to OneDrive:

Example Runtime output

Notes

When a new email arrives (V3) – This operation triggers a flow when a new email arrives. It will skip any email that has a total message size greater than the limit put by your Exchange Admin or 50 MB, whichever is less. It may also skip protected emails and emails with invalid body or attachments.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Website Built with WordPress.com.

Up ↑

%d bloggers like this: