Using Microsoft Flow to save copies of E-mail receipts

Posted Thursday, January 18, 2018 1:21 PM by CoreyRoth

If you are like me, you get a lot of receipts via e-mail for things like Internet, electricity, phone, flights, and more.  These things are usually business related, but they don't always get sent to the business account.  Before Flow, I used to go through my e-mail, save each one off as a PDF and drag it to a document library.  It was very time consuming.  Now I have automated all of this with Flow.

In my example, I am setting up a Flow to capture receipts from my Internet provider.  First, you'll need to set up connections to wherever your e-mail is coming from.  This could be Outlook (consumer), Gmail, or Office 365 Outlook.  In this example, I set up a connection to Outlook.  Then I used the trigger "When a new e-mail arrives".  After you have added the trigger, click on Show advanced options to create a filter.  You can filter by To address, From address, or the subject.  In this case, I am looking for the Subject Filter of "Your AT&T online bill is ready to be viewed".  This will trigger the flow whenever an e-mail is received with the matching conditions.

Screen Shot 2018-01-18 at 1.01.08 PM

My goal is to save the contents of the E-mail as a PDF into a document library.  There is an action that lets you convert HTML files to PDF but it only works on files stored in OneDrive for Business.  As a result, I create the HTML file first in OneDrive for Business with the Create File action.  Use the Body field from the E-mail step as the File content.

Screen Shot 2018-01-18 at 1.05.14 PM

Now use the Convert file using path (preview) action to convert the file to a PDF.  Use the Name from the Create File action as the File Path.  Make sure Target type is set to PDF (currently the only valid value).

Screen Shot 2018-01-18 at 1.07.16 PM

Finally, we want to save the file into a document library where I keep receipts.  Use the SharePoint Create File action.  Specify the URL to your site first.  Then you can specify a Folder Path.  In this case I am telling Flow to save my file in the Company Documents document library and in the Receipts subfolder.  For the File Content parameter pass the File Content output from the Convert file using path activity. 

Screen Shot 2018-01-18 at 1.13.45 PM

You want the name of the file to be unique when it gets written to the document library.  Therefore, I use concat to create a filename with the vendor in the receipt along with the date for the File Name parameter.  Here's what mine looks like.

Screen Shot 2018-01-18 at 1.15.31 PM

That's it.  At this point, your Flow is ready to go.  When the flow runs, you'll see the file in your target document library if everything is correct.  Here is what the information looks like on the file.

Screen Shot 2018-01-18 at 1.17.33 PM

Viewing the file, you will see the PDF it created.  While the conversion process picks up the HTML formatting, tables, and CSS, it doesn't pick up the images unfortunately.  However, this is good enough for me for now. 

Screen Shot 2018-01-18 at 1.18.32 PM

I thought I would share this Flow today because I found it useful.  If you found some actions that you think might work better, leave a comment.

Filed under: , ,

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required)