In this guide you’ll learn how to automatically convert the body of incoming emails to PDF using Power Automate. You can use different email services as a trigger (outlook.com, Outlook for Office 365) and send the generated PDF to your desired platform.
Steps to convert emails to PDF using Power Automate:
- Create a flow in Power Automate
- Define your action (Convert to PDF)
- Create File (define were your file will be created)
- Publish your workflow
It’s also important to note that in this specific example we convert emails to PDF and then archive them in Dropbox using Power Automate. If preferred, you can easily save the converted PDF file to another destination like SharePoint, Google Drive, OneDrive, or any platform supported by Power Automate.
From a high level, the Flow works as follows:
The full Flow can be found below. It is automatically created by the Flow Template named Convert Email to PDF and archive in DropBox. After selecting the template, make sure the following fields are changed:
- DropBox Output folder (for HTML emails): The DropBox folder to write the PDF files to.
- DropBox Output folder (for Text emails): The DropBox folder to write the PDF files to.
The Flow itself is relatively straight-forward. You will need to ensure the format of the email. Email may appear to be a simple format, but content can be represented in HTML format, Plain Text or even RTF. Depending on the format, we need to send the body either to the HTML converter or the Text converter. In this Flow, we use a simple trick, which is to check if either ‘<html’, ‘<p’ or ‘<br’ can be found in the email body. If it is found, then we send it to the HTML converter, otherwise we send it to the Text converter.
This Flow will convert emails to PDF documents.
For more details about using Muhimbi’s Flow actions, see the Core Concepts knowledge base article as well as all other Flow related posts.
Note: this flow requires a Muhimbi API key. Get a free plan with 75 operations per month or a 30 day free trial with no limitations. Sign up to create your API key.
Troubleshooting / Caveats
HTML is not the best format for print or PDF Conversion purposes. Depending on your exact needs and source material, you may need to experiment with various available settings. If you have any questions or require assistance please feel free to contact us.
Please consider the following when using Power Automate:
Modern Views: In SharePoint Online it is possible to display Lists and Libraries in Modern or Classic mode. Modern View is undergoing constant change (by Microsoft), as a result we currently only support the conversion of pages displayed in Classic View. Some Modern View pages will convert fine while others don't.
Multi Factor Authentication (MFA): An increasing number of SharePoint Online / Office 365 environments are secured using MFA. Although this is a positive development, it gets in the way of automated systems such as our HTML converter. If your environment uses MFA then please create an App password for HTML conversions, or disable MFA on your HTML Conversion account.
HTML Conversion option not displayed: The option to convert the current page to PDF is only available in Classic SharePoint pages. Modern pages currently do not provide a facility for extending the personal actions menu. We will make sure it is added as soon as Microsoft makes this functionality available.
PDF Layout does not match: By default the page being converted is optimized for print / PDF output. If you prefer the PDF to look exactly like what is displayed on screen, including user interface elements, then set the Media Type to Screen in the HTML Conversion configuration screen.
User modified content is not converted: The converter does not have knowledge about the information currently displayed in the user's browser (e.g. size of the browser window, or custom data entered, but not yet submitted to the server). The converter always requests a fresh copy of the URL and converts that information to PDF.
User specific information is missing: HTML Conversion is carried out in the context of the configured user account, though the system is not aware of the user carrying out the HTML conversion. Don't specify accounts that display more information than what the users need to have access to.