Testing out Power Automate Desktop — Empty emails from a folder in Outlook, then ping me in Teams.

Simone B
5 min readApr 22, 2022

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:

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
Fastest way to install the Machine Management extension is to open Power Automate desktop > Settings > Open Machine Settings.
The fastest way to install the Machine Management runtime, is to open Power Automate desktop > Settings > Open Machine Settings.
  • Once that’s complete, Select Machine Group
  • Select New Machine Group, name it accordingly and save
Automate Desktop > Settings > Machine Settings
Settings > Machine Settings, New Machine Group
  • Now you can add your device to the Machine Group you created.
    Select Add Machine and follow the prompts
Add your device to the Machine Group you created

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
New Flow Creation
  • 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
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 :)

Get all of the emails in my test folder, mark them as read
  • 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.
Delete emails flow
  • 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
Running the flow in Power Automate desktop directly

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
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
Give the flow a name and set the frequency
  • Select New Step so we can specify what we want to run on that schedule
Select New Step
  • 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
Premium> Desktop Flows> Run a flow built with Power Automate for Desktop

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
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
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!

--

--

Simone B

I love data, nerding, riding, lifting up heavy things & obnixious witty humour. Posts are mine & don’t represent my employer. She/her 🌈