Update Email Subjects Post-Delivery Using Power Automate and Graph API
Power Automate offers no standard action to change a received email’s subject. Instead, leverage the Microsoft Graph API through the built-in HTTP request action to modify the subject line without premium licensing.
When an email lands in your mailbox, its subject line is generally final. But what if you need to append a ticket number, update a status flag, or correct a typo after the fact? Power Automate doesn’t expose a built-in “Change Email Subject” action, but with a single HTTP request to the Microsoft Graph API you can update the subject (and other message properties) using only the standard Office 365 connection — no premium license required.
// TODO: Insert a screenshot showing a sample mailbox where subjects have been modified
Scenario Overview
Imagine a project support team that uses a shared mailbox (projects@contoso.com) to receive incoming requests. Each request must be tagged with a unique ticket number after arrival so the team can sort and track messages. The ticket number comes from an external system (for example, a Dataverse table or a SharePoint list). In this walkthrough we’ll append a static ticket number to demonstrate the technique; in a real implementation you would replace it with a dynamic value.
Step-by-Step Implementation
1. Configuring the Trigger
Create a new automated cloud flow with the Office 365 Outlook – When a new email arrives (V3) trigger. Select the Inbox folder of the shared mailbox.
In the trigger Settings, enable Split On. This ensures each incoming email is processed individually.
Next, add a Trigger Condition so the flow only runs on emails that do not already contain a ticket number. Use the expression below in the trigger condition field:
@not(contains(triggerOutputs()?['body/subject'],'[Ticket#'))
The expression checks if the subject contains [Ticket#. Only emails without that pattern trigger the flow, preventing an infinite loop after the subject is updated.
2. Building the New Subject
Because the ticket number is not yet part of the subject, we need to compose the updated string. Insert a Compose action and rename it to New Subject. Set the Inputs to:
@{triggerOutputs()?['body/subject']} [Ticket# 1001]In a production flow you would replace 1001 with a dynamic value retrieved from another step (for example, the ID of a newly created item in a SharePoint list).
3. Calling the Graph API
Power Automate doesn’t have a dedicated “update subject” action, so we’ll use the Office 365 Outlook – Send an HTTP Request action. Configure it as follows:
- Method:
PATCH - URI:
https://graph.microsoft.com/v1.0/me/messages/@{triggerOutputs()?['body/id']} - Headers: Add a new header with Name
Content-Typeand Valueapplication/json - Body:
{
"subject": "@{outputs('New_Subject')}"
}The URI references the message ID from the incoming email. The PATCH request tells Microsoft Graph to replace only the subject property on that message.
The Office 365 Outlook connection must have delegated permission Mail.ReadWrite (it usually does by default). If you receive a 403 error, verify the connection’s permissions in the Power Platform environment.
4. Testing the Flow
Send an email to the shared mailbox with a subject like “Project Alpha – budget approval”. When the flow triggers, it should:
- Detect that the subject does not contain
[Ticket#. - Compose a new subject: “Project Alpha – budget approval [Ticket# 1001]”.
- Call the Graph API and update the message.
Verify in the shared mailbox that the subject now ends with the ticket number.
Important Considerations
- Trigger behaviour: The “When a new email arrives” trigger only fires on newly delivered messages, not on updates. Once the subject is changed, the same email will not re-trigger the flow because the trigger condition now excludes it.
- Split On: Always enable when you need to process each email separately. Without it, the trigger may return multiple emails in one run and the expression
triggerOutputs()?['body/id']would not work as expected. - Dynamic ticket numbers: In a real scenario, you can generate or fetch the ticket number from any supported source (Dataverse, SharePoint, SQL Server, etc.) and pass it into the Compose action.
- Shared mailboxes: For a shared mailbox, ensure the connection used in the flow has access to that mailbox. The Graph API endpoint
/me/messages/uses the mailbox of the authenticated user. To update a shared mailbox, usehttps://graph.microsoft.com/v1.0/users/sharedmailbox@contoso.com/messages/{message-id}.
Troubleshooting Common Issues
| Symptom | Likely cause | Solution |
|---|---|---|
| 404 Not Found | Message ID is incorrect or email has been deleted | Check that the URI correctly references the message. Add the Compose action to inspect the ID. |
| 403 Forbidden | Insufficient mailbox permissions | Verify that the connection has Mail.ReadWrite. For shared mailboxes, grant full mailbox access to the account used in the connector. |
| Trigger doesn’t fire for new emails | Trigger condition too restrictive or split on disabled | Test with a simple subject and temporarily remove the trigger condition. Ensure Split On is enabled. |
| Subject unchanged but flow succeeded | The Graph API call might have been throttled or the JSON body malformed | Check the HTTP request response. Make sure Content-Type is set and the body is valid JSON. |
Conclusion and Recommendation
Using the Microsoft Graph API is a reliable, licence‑friendly way to modify email subjects after they have been received. While Power Automate offers no native action for this, the “Send an HTTP Request” action bridges the gap perfectly.
When should you use this pattern? Any time you need to enrich or correct a subject line based on business logic that runs after the email is already in the mailbox. For pre‑send modifications (for example, in a “Send an Email” action), simply set the subject parameter directly.
References
- Original inspiration: How To Change An Email Subject In Power Automate by Matthew Devaney
- Microsoft Graph API – update message
- Office 365 Outlook connector reference (Microsoft Learn) –
- Power Automate trigger conditions overview (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.