Power Automate delete emails older than [15 days example]

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.

Microsoft flow delete emails older than

Then provide the flow name and select Manually trigger a flow action. Click on Create.

power automate delete emails older than

You can see Manually trigger a flow action is added to the flow page.

Using power automate delete emails older than

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.
Using Microsoft power automate delete emails older than

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.
See also  How to Convert an Integer to an Array in Power Automate?

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
Microsoft power automate delete emails older than

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.

How to delete older emails using Power Automate

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:

>