Remove deleted e-mails with Flow


With this simple trick, you will truly delete your unwanted e-mails in Outlook.

E-mail on the web

I use Outlook on the web as my mail/calendar client. At some point, I got fed up with .pst issues where the file got corrupted and I had to clean up my machine and set up e-mail again waiting for the whole thing to sync. So one day, I decided to manage my e-mail in the browser. And I never looked back since.

Like with any other app that’s a part of Office 365, Outlook on the web became recently the primary target for deploying new capabilities. Sure, there is a case to be made for using fat clients, but for Outlook, they don’t apply to me, and so I’m happily living on the web. Well almost, because there is one thing that’s been bothering me for a long time.

When delete != delete

We all get a bunch of crap e-mail every day. Outlook does a great job of dividing your messages into relevant and irrelevant. In the end, if you’re anything like me, you will want to get rid of the unnecessary ballast and delete messages you don’t need.

When you delete a message in Outlook on the web it’s moved to the Deleted items folder. I admit it’s better than asking Are you really sure? but nevertheless, the e-mail stays there. There is a setting in Outlook that purges deleted items on every logout, but do you actually log out? I know I don’t. And so I’m faced with a reminder of 1000+ deleted items.

There is a Flow for that

Microsoft Flow is the Office macros for Office 365. You can use it to automate virtually any tedious task and removing unwanted e-mails is no different. Here’s how.

Start with creating a Flow that will run daily.

Recurring Microsoft Flow trigger configured to run daily

Next, initialize a variable that you will use to keep the number of deleted items in your Outlook.

Initialize variable action with the number of e-mails variable set to 0

Then, until the number of deleted e-mails equals 0, repeat the following steps.

Do-until loop configured to run as long as the number of deleted e-mails is greater than 0

Retrieve the list of e-mails from the Deleted items folder.

Get e-mails action set to retrieve e-mails from the deleted items folder

Update the number of deleted items in the variable so that the loop will repeat if there are still more items to delete.

Set variable action configured to update the number of retrieved e-mails

For each retrieved e-mail message, delete it, passing its ID as the parameter.

For-each loop configured to iterate over the retrieved e-mails and delete each one of them

That’s it! From now on, all you have to do is to delete unwanted messages and the Flow that you have just built will clean up your deleted items daily for you, without you having to think about it ever again.

Others found also helpful: