How To Change An Email Subject In Power Automate

How To Change An Email Subject In Power Automate

Power Automate can be used to change an email subject line. There is no dedicated flow action to do this. However, we can call the Microsoft Graph API with the Outlook Send An HTTP Request action and use it to change the email’s subject if we know the right endpoint. Best of all, it doesn’t require any premium licensing.

Table of Contents
• Introduction: The IT Helpdesk Case Id AutomationConfigure The "When A New Email Arrives" Trigger SettingsChange The Email Subject Using The Microsoft Graph APIRun The Flow To Update An Email Subject In Power Automate




Introduction: The IT Helpdesk Case Id Automation

The IT helpdesk at a financial services company tracks each case by assigning it a unique case id. When a new request for help email is received in their inbox the helpdesk uses Power Automate to change the subject line to include a Case Id.



For example, [Case Id #1] appears at the end of this email’s subject line.




Configure The “When A New Email Arrives” Trigger Settings

Open Power Automate and create a new automated flow using the Office 365 Outlook – When A New Email Arrives (V3) trigger. Choose the Folder named Inbox.



Go to the trigger’s Settings and enable Split On. This tells Power Automate to evaluate each email individually as it arrives in the inbox.



We also want to determine whether the flow needs to add a Case Id or if it already has one.



Use this expression in the Trigger Conditions to only change the subject line of emails with no Case Id.

@not(contains(triggerBody()?['body/subject'],'[Case Id#'))




Change The Email Subject Using The Microsoft Graph API

The new email subject line should include the original subject and then append a tracking number to the end. Add a Data Operations – Compose action to the flow with the following values in the Inputs field. In this tutorial we will use a hardcoded value since the focus is on how to update the Subject Line.



There is not any Power Automate action to change a subject line so we must use the Microsoft Graph API instead. Insert the Office 365 Outlook – Send An HTTP Request action into the flow and select the PATCH method.



Use the following URI to update the message object.

https://graph.microsoft.com/v1.0/me/messages/@{triggerOutputs()?['body/id']}



Supply this JSON to the Body of the action.

{
  "subject": "@{outputs('Compose:_New_Subject_Line')}"
}



Write this code in the Content-Type field.

application/json




Run The Flow To Update An Email Subject In Power Automate

That’s all we need to change the email subject line of an incoming message. Press the Test button in the Power Automate editor and then send an email to the target inbox.



The flow will complete successfully.



And the email subject line will be updated to include [Case Id# 1] at the end.





Questions?

If you have any questions or feedback about How To Change An Email Subject In Power Automate please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.

Matthew Devaney

Subscribe
Notify of
guest

12 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Michael Damaschke
Michael Damaschke
5 months ago

Hello Matthew
Thanks for the article but I realised that I can use only the follwoing Expression for the trigger condition:
@not(contains(triggerBody()?[‘subject’],'[Case Id#’)) your one with [‘body/subject’] was not working as expected. I never got it triggerd.

Cheers
Michael

Michael Damaschke
Michael Damaschke
5 months ago

Hello Matthew
Well I am using the old one, I don’t like the new one.
A kind of pseudo Nintx implimantation thought.

Michael Damaschke
Michael Damaschke
5 months ago
Wayne Wallace
Wayne Wallace
5 months ago

Mattew, I had the same issue as Michael and I am on the classic version. I made the change as Michael has indicated removing body/ and it worked great. Thanks!

Gina
Gina
5 months ago

In the scenario where you’re adding a case ID, how would dynamically get the right case ID to add to the subject?

Sam
Sam
5 months ago

Thank you for sharing, that’s really helpful. In my case, I tried it in a shared mailbox and unfortunately, it didn’t work. Do you have any idea what could be the reason for this?

17-02-2024_11-45-04.jpg
Gcobani Mkontwana
Gcobani Mkontwana
2 months ago

I am using a Compose action, how will my expression for creating a dynamic email id of a user, that can be used on email action trigger? as AssignedTo?

Carol
Carol
10 days ago

Hello, Matthew:

I’m testing with a sharemailbox, but I get this error after some successful executions. Can you help me?

imagenError.png