Testing out Power Automate Desktop — Empty emails from a folder in Outlook, then ping me in Teams.
I’m a big fan of Power Automate cloud flows so I was excited to see if could further automate my entire life using Power Automate Desktop. Spoiler — I haven’t yet, but there is potential!!
Follow along to set up a test flow that is triggered by Power Automate cloud and runs on your local device. This test flow will run weekly, mark all emails in a folder as read, delete them and ping you in teams to let you know it complete.
Pre-Requisites
To follow on for this quick tutorial you’ll need to:
- Install Power Automate Desktop
- Create a folder in MS Outlook (aka Inbox\Folder Name)
- Fill that folder up with junk emails that you’re happy to delete
Create the Machine Group & add your device
First we need to Register your local machine using the machine management runtime. This will allow Power Automate to use your local machine to run flows.
- Open up Power Automate Desktop > Settings > Machine Settings
- Install the machine management runtime
- Once that’s complete, Select Machine Group
- Select New Machine Group, name it accordingly and save
- Now you can add your device to the Machine Group you created.
Select Add Machine and follow the prompts
Create a Power Automate desktop flow to empty out the test email folder
Let’s build our email clean-up flow:
- From Power Automate desktop select New Flow
- Give your flow a name and select Create
- The first thing we want to do is launch Outlook. To do this open Actions
- Expand Outlook
- Drag Launch Outlook to the main canvas and save
- For this demo, I want to get all of the emails in my test folder, mark them as read and delete them periodically. To do this, use the Retrieve Emails Action.
- Drag Retrieve Emails to the canvas and set:
- Outlook Instance: %OutlookInstance%
- Account: Your email address
- Mail Folder: The path to the folder for eg: \\Inbox\Test Folder
- Retrieve: All Messages, Unread Messages or Read Messages
- Mark as read: On
Save this action’s customisations. - This creates a %RetrievedEmails% variable that we can call in the next step
NB: If you want to make sure you’re targeting the folder correctly, run the flow here and see the emails are marked as read but left in place :)
- Now, lets delete all of the emails and make our lives wonderful
- Drag the Process Email Messages in Outlook flow to the canvas and set:
- Outlook Instance: %OutlookInstance%
- Account: Your email address
- Email Messages to Process: %RetrievedEmails%
- Operation: Delete Email Messages
Save this action’s customisations.
- Run the flow to test it and see that the emails are all deleted as expected. AND THEN put them all back and mark them as unread so we can test again in a minute :P
Schedule the Desktop Flow using Power Automate in the cloud
Lets make this flow run weekly without any intervention from us, self driving email. you love to see it.
- Open up Power Automate in your online portal
- Select Create Flow > Scheduled cloud flow
- Give the flow a name and set the frequency. I set mine to Friday because inbox zero on a Friday is the best.
- Select Create
- Select New Step so we can specify what we want to run on that schedule
- Select Premium> Desktop Flows> Run a flow built with Power Automate for Desktop
- Set the following settings:
- Desktop Flow: The name of the desktop flow you created earlier
- Run Mode: Attended
- Priority: Normal
Note: when you add this step, Power Automate asks you for your machine sign in details.
If you are going to build something that will be used by anyone else for any reason, please don't build it on your local machine with your own credentials. As soon as you show people your amazing invention it will immediately be considered as “Production” and your machine/user account will forever be untouchable.
The sysadmin in me is begging you to avoid that happening!
- Select New Step so we can notify ourselves in Teams when our flow has run
- Search for Teams and select Post a message in a chat or channel
- Configure this step to send you a Teams Flow bot message when the flow is complete:
- Post As: Flow bot
- Post in: Chat with Flow bot
- Recipient: Your teams ID
Save the flow
- Run your flow to test it out. You should see:
- All emails in the folder marked as read
- All emails in the folder are deleted
- Flow bot message to tell you you’re a star
Pretty cool and so easy to set up!
I need to do some more discovering but if you have any amazing desktop flows please comment here, or ping me on Twitter or LinkedIn to let me know what they are!