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:
In order to complete all this you will need the following.
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.
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.
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.
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.
Here is a high level outline of the Flow we are going to build.
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.
(?:(?:https?|ftp)://|b(?:[a-zd]+.))(?:(?:[^s()<>]+|((?:[^s()<>]+|(?:([^s()<>]+)))?))+(?:((?:[^s()<>]+|(?:(?:[^s()<>]+)))?)|[^s`!()[]{};:'".,<>?«»“”‘’]))?
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.
Original Post http://www.richardawilson.com/2021/06/power-automate-desktop-example.html