I'm building a Power Automate flow that should trigger when a new email arrives in any folder (not just the inbox). I want the flow to automatically add a category (like "BOARD") to the email once it arrives.
My question is, how can I build a Power Automate flow that adds a category to emails in all folders, not just the inbox? I'm using the 'When a new email arrives' trigger, but it only works for the inbox. How can I make it detect emails in all folders and successfully apply a category like 'BOARD'?
Here's what I'm trying to do:
- Trigger the flow when a new email arrives in any folder.
- Retrieve a list of all mail folders (since emails can be routed to subfolders).
- Identify the folder the email is in.
- Update the email by adding the "BOARD" category (or another category).
My current approach:
- Trigger: I'm using the "When a new email arrives" trigger, and I set it to the Inbox for now, but I want to make it flexible enough to check all folders.
- Retrieve all folders: I’m calling
https://graph.microsoft.com/v1.0/me/mailFoldersto fetch all mail folders via an HTTP request. - Identify the folder: After the trigger, I’m trying to find out which folder the email came from and get the email’s details.
- Update the email: I’m sending a PATCH request to Microsoft Graph API to add the "BOARD" category to the email.
Here’s the PATCH request I’m using:
PATCH https://graph.microsoft.com/v1.0/me/messages/{message-id}
Content-Type: application/json
Authorization: Bearer {token}
Body:
{
"categories": ["BOARD"]
}