Power Automate Desktop Example - Downloading Image From Email To Network Drive
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.
Prerequisites
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.
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-z\d]+\.))(?:(?:[^\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.
Test It!
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.
Glad to visit this blog, really helpful. Gathered lots of information and waiting to see more updates.
ReplyDeleteRPA Training Institute in Chennai
RPA Certification Course
RPA course in Coimbatore
RPA Analyst
I found your blog on Google and read a few of your other posts. I just added you to my Google News Reader. You can also visit RPA Companies In India for more Webuters Technologies Pvt. Ltd. related information and knowledge, Keep up the great work Look forward to reading more from you in the future.
ReplyDeleteI like this article. It is very good to read. Keep updating.
ReplyDeleteAccounting Software Singapore
PSG Grant Accounting Software
E invoicing Singapore
A very awesome blog post. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. Zendable
ReplyDeleteExcellent Blog, I like your blog and It is very informative. Thank you
ReplyDeleteRPA Online Course
Pega Online Course
Ranorex Online Training
Really an informative blog...Thanks for sharing an informative article with us.
ReplyDeleteIoT Training in Chennai
IoT course in Chennai
Thanks for taking your valuable time to share this awesome article with us. This is really informative. Looking forward to learn more from you.
ReplyDeleteCloud Computing Training in Chennai
Cloud Computing Online Training
Cloud Computing Course in Coimbatore
Nice Blog, it is very Impressive.
ReplyDeleteRPA Online Course
RPA Course in Chennai
RPA Course In Bangalore
Great info. The content you wrote is very interesting to read. This will be loved by all age groups.
ReplyDeleteDevOps Certification in Chennai
DevOps Training Online
DevOps Certification in Ciombatore
Nice blog, it is very impressive.
ReplyDeleteDifferent Types of Internet of Things
Types of IoT
Great blog with good information.
ReplyDeletePega Training in Chennai
Pega online Training
this was an awesome blog . thank you for sharing this konwlwdge with us.
ReplyDeletepega online training
pega training
What file formats are typically used for images when downloading them from emails to a network drive? cymath
ReplyDelete