Convert Email Attachement to PDF using Power Automate

In this guide you’ll learn how to automatically convert all email attachments to PDF and archive them to your desired file service using Power Automate. For this example the Flow is triggered when an email containing attachments is received in Office 365 Outlook. The Flow then iterates over all the attachments and converts the ones it knows how to convert to PDF. The resulting PDF files are archived to a OneDrive for Business folder, which will sync the files to other systems if needed.

It’s also important to note that this example can easily be modified to use different email providers (Outlook.com, Gmail) and the converted attachments can be written or emailed to any of the 100+ available Flow services, including Google Drive, Box.com, DropBox, OneDrive, and SharePoint.

From a high level, the Flow works as follows:

The steps are missing here

PDF Attachments - Overview

The full Flow can be found below. You can automatically create this by the Flow Template named Archive email attachments in PDF format to OneDrive. Once you have this template, you need to specifically fill out the following:

  • Save to OneDrive – Folder path: Specify the path in OneDrive where the converted attachments will be written to.

In this particular example, all files are written to a flat folder. If we use the original attachment file name to save the PDF in OneDrive then files would potentially be overwritten if a single email has multiple attachments with the same name (rare but possible) or multiple emails are processed and some use an attachment with the same name (more common).

To get around this we use the Compose action to convert the time that the workflow is executed, which matches the time the email is received, and clean it up for use in file names (by replacing ‘:’ with ‘-‘). We then concatenate it to each file name. If your requirements are different then feel free to change this or add this time stamp to the OneDrive path to automatically create a sub-folder for each email and their attachments.

PDF Attachments - Detail - Part1

PDF Attachments - Detail - Part2

One of the tricks we use in this example is changing the default ‘Fail on error’ option in the Muhimbi Workflow actions from Yes to No. As a result, the Flow will not fail if an unsupported or broken attachment type is encountered. By evaluating the Result Code we can decide if the operation was successful and write the PDF to OneDrive. For more details about this concept see the Error handling section in our Core Concepts knowledge base article.

You can now publish the Flow and send an email containing some MS Word, MS Excel, MS PowerPoint or other supported files types to the email address associated with the Flow. You will find that after a few seconds, PDF will appear in the destination folder.

For more details about using Muhimbi’s Flow actions, see the Core Concepts knowledge base article as well as all other Flow related posts.

Additional Resources

Power Automate Templates

Articles

Have a Question?
We’re Always Happy to Help.

© Muhimbi Ltd. 2008 - 2023
This website uses cookies to ensure you get the best experience. Learn more