V2: Convert Emails and Attachments to PDF in Power Automate

August 21st 2020
Back to all blogs

Ok, you got me! We released a similar post on this topic early this year… so why another post? We have just released a new Power Automate action – Convert Email Message which means you can convert your email and attachments to PDF with ease.

This new action significantly simplifies the conversion of an email message (EML or MSG) and contains attachments to a PDF document in Power Automate. The new act also provides the capability to convert MSG or EML files previously exported and stored outside of a mailbox.

Whilst the approach outlined in our previous post is still valid, we recommend using this new action.

This post covers two examples:

  • Converting new email messages received into a Microsoft 365 mailbox to PDF
  • Converting existing email files to PDF

Convert a new Outlook 365 Email Message to PDF

1. Launch Power Automate

2. Create a new Flow using the ‘Automated — from blank‘ option

3. Enter a name for the Flow, select the Office 365 Outlook ‘When a new email arrives (V3)‘ trigger action and click ‘Create.

convert email to pdf

4. Configure the Office 365 Outlook ‘When a new email arrives‘ trigger action as appropriate to ensure your Flow is only triggered when required.

NOTE: The ‘Include Attachments’ property must be set to ‘Yes‘ if you wish to convert the email and the attachments it contains to PDF. After changing this setting, make sure you do not use previous test data from your run history, as the historical data will still exclude attachments even after changing this setting.

5. Add the ‘Export email (V2)‘ Office 365 Outlook action

5.a. Message Id: Select the ‘Message Id‘ property from the Office 365 Outlook ‘When a new email arrives (V3)‘ trigger action

NOTE: The ‘Export email’ action exports emails in the EML file format, not the MSG file format.

6. Add the Encodian ‘Convert Email Message‘ action

6.a. Filename: Enter a filename making sure the file extension is set to ‘eml‘, for example, email.eml

6. b. File Content: Select the ‘Body‘ property from the ‘Export email‘ Office 365 Outlook action

6. c Merge Attachments: Select ‘Yes.

Good news that is all you need to do! The ‘Convert Email Message‘ action will dynamically extract the attachments and convert them to PDF. It will also alter the email message and compile a single PDF document; super simple! As an example, I will add the PDF document created by the Encodian action to SharePoint.

7. Add the SharePoint ‘Create File‘ action

7.a. Site Address: Enter the location of the target SharePoint site

7. b. Folder Path: Select the target SharePoint library/folder

7.c. File Name: Select the ‘Filename‘ property from the ‘Convert Email Message‘ action

7.d. File Content: Select the ‘File Content‘ property from the ‘Convert Email Message‘ action

This flow is complete, and all emails that meet the trigger criteria will be converted to PDF, including their contained attachments.

convert email to pdf

The resulting document will contain both the email and the attachments:

Converting an existing email file (MSG or EML) to PDF

For this quick example, I will obtain and convert an MSG file from a SharePoint library and convert it to a PDF.

1. Create a new Flow using your desired trigger action; for this example, I have used the manual trigger action.

2. Add a SharePoint ‘Get file properties‘ action and configure it as required to target the selected EML or MSG file.

3. Add a SharePoint ‘Get file properties‘ action

3.a. Site Address: Enter the same value provided for the site address property in step #2

3.b. File Identifier: Select the ‘Identifier‘ property provided by the SharePoint ‘Get file properties‘ action

4. Add the Encodian ‘Convert Email Message‘ action

4.a. Filename: Select the ‘File name with extension‘ property provided by the SharePoint ‘Get file properties‘ action.

4.b. File Content: Select the ‘File content‘ property provided by the SharePoint ‘Get file content‘ action.

4. c Merge Attachments: Select ‘Yes.

convert email to pdf

5. Add the SharePoint ‘Create File‘ action

5.a. Site Address: Enter the location of the target SharePoint site

5. b. Folder Path: Select the target SharePoint library/folder

5. c. File Name: Select the ‘Filename‘ property from the ‘Convert Email Message‘ action

5.d. File Content: Select the ‘File Content‘ property from the ‘Convert Email Message‘ action

This image has an empty alt attribute

That’s it! The target file (MSG or EML) will be obtained from SharePoint, converted with contained attachments to a PDF file and then uploaded to SharePoint!

Finally

We hope you’ve found this guide useful, and as ever, please share any feedback or comments – all are welcome!

You can find further documentation and guidance on the Encodian support portal: Convert Email Message

Author
Jay Goodison

Managing Director

Back to all blogs

You might also be interested in...