Subscribe to News feed

Use Microsoft Flow to convert and archive incoming emails in PDF format

Posted at: 2:45 PM on 12 April 2017 by Muhimbi

gmailAs part of our ongoing series about using the Muhimbi PDF Converter Services Online in combination with Microsoft Flow, Logic Apps and PowerApps, we present an example about how to automatically convert the body of incoming emails to PDF, and archive the results in DropBox.

For those not familiar with the product, the Muhimbi PDF Converter Services Online is a popular product to PDF Convert, Merge, Watermark, Secure and OCR files from Microsoft Flow, Logic Apps, PowerApps as well as your own code using C#, Java, Python, JavaScript, PHP, Ruby and most other modern platforms. Leave a message below or contact us if you have any questions.

 

Earlier today we were contacted by a Flow user who wanted to convert incoming emails to PDF. Now, the Muhimbi PDF Converter actually comes with an awesome email to PDF converter, but it expects an MSG or EML file as the input. Unfortunately the various email based triggers that currently ship with Flow (Outlook for Office 365, Outlook.com, Gmail) do not provide files in this format (Please vote here to have it added).  Instead, they expose the message Body, Subject, From, To, Attachments etc.

Even though the MSG file is not available, all the individual elements are. We managed to ‘knock up’ a functional email to PDF converter using Flow in absolute no-time. You may want to customise it further by using the Compose Action to add the subject, from and to fields to the body before sending it into the PDF Converter. You can even use our Merge documents Action to convert the attachments and merge them all, alongside the main body, into a single PDF.

Similar to our other examples, this Flow is just a starting point. You can use a different email service as a trigger (outlook.com, Outlook for Office 365) and send the generated PDF to SharePoint, OneDrive, Google Drive, email, you name it.

 

From a high level, the Flow works as follows:

Convert Email Body to PDF - Overview
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, but there is one complication. Email may appear to be a simple format, but content can be represented in HTML format, Plain Text and 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 and dirty trick, which is to check if either ‘<html’, ‘<p’ or ‘<br’ can be found in the email body. If it is then we send it to the HTML converter, otherwise the Text converter.

 

Convert Email Body to PDF - Detail - Part 1Convert Email Body to PDF - Detail - Part 2Convert Email Body to PDF - Detail - Part 3 
That is all there is to it. I left this flow running by mistake and when I came in the next day DropBox had synced dozens of emails to my local PC. They looked brilliantly though when opened in a PDF reader.

 

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

If you have any questions about extending this template, or implementing it in your environment, then please leave a message below or contact our friendly support desk. We are here to help.

.

Labels: , , , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

Need support from experts?

Access our Forum

Download Free Trials