In this Power Automate tutorial, we will see how to delete older emails using Power Automate.
We will create an Instant cloud Flow to get the Top 25 emails from Outlook Inbox. Because to get the emails we will use the ‘Get emails’ action and this action can retrieve the maximum email i.e. 25. Once we get the 25 emails, we will put a condition that will check whether the email received date is 15 days older or not.
If the condition is true that email will permanently delete from Outlook inbox.
Now let’s see how to delete emails older than 15 days from Outlook using Power Automate.
How to delete older emails from Outlook using Power Automate
Here we will see how to delete 15 days older emails from Outlook using Power Automate.
Step 1: Login to Power Automate -> then click on +Create -> select Instant Cloud flow.
Then provide the flow name and select Manually trigger a flow action. Click on Create.
You can see Manually trigger a flow action is added to the flow page.
Step 2: Now we will get emails from Outlook, so click on the +New step -> select Get emails (V3) action.
Then provide the below information:
- Folder: Select the Inbox folder.
- Fetch only Unread message: Select No from the dropdown.
- Include Attachments: Select Yes.
- Top : Provide 25, i.e. the maximum limit.
Step 3: Now we will check the receive date of emails are older than 15 days. So, click on the +New step -> select Condition action. Then provide the below information:
- Choose a value: Provide the below expression. Also, it will add Apply to each action.
formatDateTime(items('Apply_to_each_3')?['receivedDateTime'], 'yyyy-MM-dd')
- Operator: Choose the operator is less than
- Choose a value: Provide the below expression :
addDays(utcNow(),-5,'yyyy-MM-dd')
Now, if the condition is true, then in If yes part, click on Add an action -> select Compose action. Then provide the below information:
- Inputs: Select Received time from dynamic content.
After that we will delete emails from Outlook older than 15 days, so click on Add an action -> select Delete email action. Provide the below information :
- Message Id: Select Message Id from dynamic content
Step 4: To run the flow manually, save the flow, click on the Test icon -> select Manually -> click on Done. Then configure the connectors, click on Run flow action ->then click on Done and your flow run successfully.
In the below screenshot, you can see that Outlook contains all Unread emails, so, the count is 2136. After deleting 8 emails, it contains 2128 emails.
This is how we can delete older emails from Outlook using Power Automate.
Conclusion
In this Power Automate tutorial, we saw an example of how to delete emails that are older than 15 days from Outlook using Power Automate.
You may like the following Power Automate tutorials:
- check if a file exists in the SharePoint document library in Power Automate
- Copy Data from One Excel to Another Excel in Power Automate
- Create an HTML Table from Excel in Power Automate
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com