The way I manage my email might seem a bit strange. Due to working in IT, I get lots of emails. Some emails need action, some are regular emails, and some are notifications I want to know about as soon as they happen. I feel like a normal person would make an Outlook rule to move emails into folders and just check those folders when needed.
The problem I have with dumping emails into folders automatically is when I only have my phone on me, I won’t know if a new email comes in when it’s auto-moved to a folder, so I’d have to keep checking the folders, and that doesn’t work with my workflow.
An example is I get notifications when backups run. If a backup is successful, I have an activated Outlook rule that moves the email into a folder. However, if a backup has an issue or something like that, I want it in my inbox so I see it immediately, no matter what device I’m using.
After I’ve addressed the email, I could move it into a folder. But that is a manual step, I’d rather have an automated way. Also, it doesn’t scale well if you get a lot of emails, and due to the nature of IT and alerts, I get lots of emails for all sorts of things that I want to see, but after I’ve read the email, I want the email to get filed away correctly.
I used to select blocks of emails and move them into folders. However, I’ve accidentally moved an email I needed to reply to into a folder and didn’t notice. If I don’t have a way to move the emails around, an email I need to action could also get lost in the noise of other emails.
A normal person might say to use a different system for alerts. While that’s valid, the issue I have is that’s another system that I’d need to keep checking when I’m not in front of a computer, and I don’t want to do that because I am stubborn and my current system does work, which is why I prefer email notifications.
I expressed the issue of my email clutter to a friend, and they told me about a system they’ve been using to help with it. They use Outlook rules that aren’t enabled to move emails around to different folders. They trigger the rules by using a macro in Outlook.
I tried the Outlook rules macro option, and it worked wonderfully with the one catch you need to enable macros in Outlook. I am worried that having macros enabled in Outlook will increase the attack surface for my account.
Rather than using macros, I found a way to do the same thing but with PowerShell and com objects. This works great, but you have to have Outlook open for it to work, and it doesn’t work with New Outlook. Currently, there doesn’t seem to be any support for com objects in New Outlook.
I went down the rabbit hole of figuring out how I could upgrade the script to support moving emails without using com objects. The rabbit hole led me to Microsoft Graph. With Microsoft Graph, there is a way to retrieve a user’s Outlook rules, but there doesn’t appear to be a way to execute the rules on demand like the macro and com object methods did.
However, Microsoft Graph does support moving emails around. Most of the Outlook rules I use to move emails around are basic rules that can be easily rebuilt using Microsoft Graph. I now have a script that I’m calling Outlook Email Mover that moves emails around based on some provided parameters, which is exactly what an Outlook rule does.
The Script
Outlook Email Mover uses Microsoft Graph to connect to the user’s mailbox and move emails around.
You can find the script on my GitHub https://github.com/thedxt/Outlook-Email-Mover
Prerequisites
How It Works
Outlook Email Mover uses Microsoft Graph to connect to a user’s mailbox. The required scope is "Mail.ReadWrite"
.
Inside the Outlook Email Mover script is a function called Outlook-email-mover-connector
.
The Outlook email mover connector is a function you can use to connect to Microsoft Graph. You can also connect to Microsoft Graph yourself and not use the function as it is optional.
…