Automated Email Categorization with Power Automate and Graph API
Apply custom Outlook categories to incoming messages based on conditions, using a simple PATCH request to the Microsoft Graph.
Outlook categories are a lightweight way to tag emails with a coloured label that stays visible in the message list. While Power Automate includes many built‑in actions for Outlook, there is no direct “Set category” action. Fortunately, you can achieve it with the Send an HTTP Request action inside the Office 365 Outlook connector—no premium licence required. This action calls the Microsoft Graph API and can read or update any message property, including the categories array.
In this article we’ll build a flow that automatically applies a category to new emails based on a subject‑line keyword. The same technique works just as well for sender addresses, sender domain, or any other trigger condition.
Scenario: Help Desk Mailbox Auto‑Tagging
Your company runs a shared help desk inbox (e.g. support@company.com). Every time a client submits a request, they send an email with a subject that contains [Ticket], for example:
Subject: [Ticket] Printer offline – urgent
You want all such messages to be labelled with a “Support Ticket” category as soon as they arrive, so your team can spot them immediately.
Before You Start: Create the Category in Outlook
The category must exist in the mailbox that the flow will monitor. In Outlook on the web, right‑click any message, choose Categorize, then Manage Categories. Add a new category called Support Ticket and pick a colour. Close the management window. This step is required only once.
Building the Flow
1. Trigger: When a New Email Arrives (V3)
Create an automated flow from blank and add the When a new email arrives (V3) trigger from the Office 365 Outlook connector. Set the folder to Inbox. If you are monitoring a shared mailbox, you can use the “Shared mailbox” parameter; otherwise, the flow runs on the mailbox of the signed‑in user.
Open the trigger settings and enable Split On. This ensures each email is processed individually, which is essential when multiple emails arrive at the same time.
2. Condition: Identify Target Emails
Insert a Condition action. Configure it to check whether the subject contains [Ticket]. The dynamic expression looks like this:
@contains(triggerOutputs()?['body/subject'], '[Ticket]')
Place this expression in the left side of the condition, choose contains as the operator, and enter [Ticket] on the right side.
3. Apply the Category with a PATCH Request
Inside the If yes branch, add the Send an HTTP Request action from the Office 365 Outlook connector. Configure the fields as follows:
- Method:
PATCH - URI:
textPATCH URI
https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages/@{triggerOutputs()?['body/id']} - Headers (add via “Advanced” options):
Key:
Content-Type, Value:application/json - Body:
jsonRequest body
{ "categories": ["Support Ticket"] }
The triggerOutputs()?['body/id'] expression extracts the unique identifier of the incoming message. The PATCH request updates only the categories field on that message.
4. Test the Flow
Save the flow and start a manual test. Send an email to the monitored inbox with a subject that contains [Ticket], for example:
To: support@company.com Subject: [Ticket] Account access issue
A few seconds later the flow should complete successfully. In the inbox the message will display the “Support Ticket” badge alongside its subject.
Important Considerations
- Pre‑create the category. While the Graph API accepts any string in the categories array, Outlook will only show a coloured badge if the string matches a category that has been defined in the user’s category list. If you use a new string, it may appear without a colour until it is synced.
- Permissions. The HTTP request action inherits the OAuth token of the Outlook connection. The user who creates the flow must have granted Mail.ReadWrite delegated permission (this happens automatically during first connection). When you share the flow, each person must consent separately.
- Multiple categories. You can apply more than one category by expanding the array:
["Support Ticket", "Priority"]. - Alternative conditions. Instead of subject‑based detection, you could filter by sender address, domain, message importance, or any property exposed by the Outlook trigger.
Troubleshooting
| Symptom | Likely Cause | Resolution |
|---|---|---|
| Flow fails with HTTP 403 | Insufficient permissions | Re‑authenticate the connection and check that Mail.ReadWrite was consented. |
| Category not displayed in Outlook | The category name does not match exactly (case‑sensitive) or has trailing spaces | Verify the name in the JSON body matches the category list in Outlook Web. |
| Flow runs but message is not updated | The message ID is incorrect or the URI uses the wrong folder | Check the value of triggerOutputs()?['body/id'] in the flow run output. |
Conclusion
The Send an HTTP Request action inside the Office 365 Outlook connector gives you direct access to the Microsoft Graph API, allowing you to set properties that the standard actions do not expose. Applying an email category is one practical use—you can extend the same idea to flag messages, move them to custom folders, or add extended properties.
This approach works with standard Power Automate licenses and runs under the security context of the signed‑in user, so you get the flexibility of the Graph API without the overhead of a custom connector.
References
- Original article by Matthew Devaney: How To Set An Email Category In Power Automate
- Microsoft Graph API – Update message (Microsoft Learn)
Core principles for resilient, maintainable, and efficient cloud flows, distilled from real-world implementations.
Build flows that gracefully handle failures and automatically notify you with run details.
Discover the trade-offs between Content-ID, Base64, and the Microsoft Graph API for embedding images in Power Automate emails. This guide covers which method works best for Outlook, Gmail, and more.