After watching the RPA (Robotic Process Automation) demo from Steve Winward Real-Life Use case using AI Builder Form Processing with Power Automate Desktop I have been looking for ways to utilize Power Automate Desktop Flows in order to make my life a little easier. Yesterday like every day I started clicking through the emails that I receive from my kids schools. I open each email, download the image, then move the image to a network drive on my computer. This takes me a few minutes every day but my kids are worth it 🙂 This scenario was a perfect one for me to automate using Desktop Flows since they can access the network drive on my desktop.
The basic flow of the solution will be as follows:
- A Power Automate Cloud Flow will be triggered to run whenever a new email comes into my Gmail account with a specific tag.
- The Cloud Flow will gather up all the information needed to run the Desktop Flow
- The Cloud Flow call the Desktop Flow by connecting through an On-Premise Data Gateway that is installed on my desktop.
- The Desktop Flow will download the image and save it to my network drive.
In order to complete all this you will need the following.
- Power Apps Environment. If you don’t have one you can try it out by signing up for a Developer Plan here.
- Power Automate Desktop. This needs to be installed on your computer, download it here.
- On-Premise Data Gateway. This is how the online Power Automate cloud flows will connect to your Desktop Flows. You can download it here. Instructions for installation can be found here.
- Application registration for Gmail within the Google console. You cannot use the default shared application because it’s not compatible with the Encodian actions or any other external Flow actions. Learn how to create this here.
- API key for Encodian to utilize their Regex action in your flow. You can sign up for one here
Inspecting the Email
For this example I’m using emails supplied by a service called Tadpole which my kids school uses to send out images and notification. The first thing I had to do was use the developer tools (F12) within the browser to help me understand how the urls were formatted for the service and how they worked. After searching through the html I figured out the formatting and found that if i used one of the parameters found in the one link for d=t that it would download the full size image.
Add Gmail Label and Filter
The first thing i did was went into my Gmail and created a new label for the incoming emails. The name of the service the school use is Tadpole so i made that my label. I think created a filter so that all emails coming from the Tadpole address would get that label applied. All of this is important because otherwise your Flow will run on everything in your Inbox which could be a lot of messages and you could end up running into API limits for Flow depending on your license.
Create the Desktop Flow
The desktop flow will download the image using it’s url and save it to to the network drive. To get started open the Power Automate Desktop application you have installed and create a new Flow.
The first thing we need to do is define the input variables we will use. We will later be passing the data into these variables from the Cloud Flow created later.
Now we can start adding actions to the Desktop flow. The first one will be a Convert text to datetime action which we will use to transform the input variable from the flow into a datetime which will allow us to do some string formatting faster.
Next we will do some formatting on our date time to create flow variables which we will use later.
Check to see if the network drive folder exists and if not create it.
Finally we will download the file using the url provided as an input variable and save it to our network drive folder.
We have now successfully created our Desktop flow. Make sure you save it and then you can test it by clicking the Run button in the editor.
Create the Cloud Flow
Now that we have created our Desktop Flow we need to run it any time an email arrives in our Tadpole inbox. This flow also needs to extract the rrl for the image and pass that information to the Desktop Flow.
Now let’s get started building! We will start by creating a solution in the maker portal.
Add a new Cloud Flow.
Setup for our Gmail trigger. Again if you haven’t created a new Application within the Google console you should do that now using the instructions located here.
All the emails that contain images have kids names at the beginning of the subject so i will set up a condition to make sure that this is an image email and also extract that data so i can use it to save the image later.
We need to get all the urls contained in the email so we will use the Encodian Regex action here to find them. Here is the Regex you will need to find all the urls in the body of the email.
Now that we have all the urls in the message we need to look at them all and see which one is the image. We will also do some parsing of the url to make sure we get the full size image by appending the ?d=t property to the url.
Last but not least we will connect to the Desktop Flow we created earlier and pass in all the information we have collected from the email.
In order to test my flow I added another Gmail filter that would tagged any email coming from myself with my kids names in the subject. This allowed me to then forward old email to myself for test processing.
For moew great content click here.
About the Author:
Columbus, Ohio, United StatesI am a Solution Developer utilizing Microsoft Dynamics at ActioNet.
Wilson, R. (2021). Power Automate Desktop Example – Downloading Image From Email To Network Drive. Available at: https://www.richardawilson.com/2021/06/power-automate-desktop-example.html [Accessed 23rd July 2021].