This guide explains how to create a Power Automate flow that automatically moves an entire email conversation thread into a nominated folder when a reply is received from:
This ensures the automation only applies to invoice threads that HAVE successfully made their way into Caresquare.
As such, any unmoved emails in your inbox are those that did NOT successfully make their way into Caresquare, and thus require manual intervention and investigation. This investigation can be coupled with the Failed Uploads section in Caresquare to view failure reasons.
What the Flow Will Do
When a new email arrives in the shared mailbox, the flow will:
Check whether the email is from
[email protected]If it is not, the flow stops
If it is, the flow finds all emails in the same conversation thread
Move every email in that thread into the nominated folder
Final Flow Structure
When a new email arrives in a shared mailbox
↓
Get email details
↓
Check if the sender is Caresquare
↓
If yes, find all emails in the same conversation thread
↓
Move each email to the nominated folder
Step 1 - Create a New Automated Cloud Flow
Navigate to Microsoft Power Automate
Login
Select Create
Select Automated cloud flow
Enter a flow name, for example:
Move Caresquare Invoice Threads to Folder
Search for the trigger:
When a new email arrives in a shared mailbox (V2)
Select the trigger
Click Create
Step 2 - Configure the Shared Mailbox Trigger
In the trigger step:
Enter the shared mailbox address you want the flow to monitor
This means the flow will start whenever a new email arrives in that shared mailbox.
Step 3 — Add “Get email (V2)”
Select + New step
Search for:
Get email (V2)
Configure the action:
Field | Value |
Message Id | Select Message Id from the trigger |
Original Mailbox Address |
|
Include Attachments |
|
Important Note
Setting Include Attachments = No does not exclude emails with attachments.
It simply prevents Power Automate from loading the attachment files during this step.
Step 4 - Add a Condition to Check the Sender
Add a new step
Select:
Condition
Set the condition to:
From address
is equal to
[email protected]
If it is easier to use the expression editor, use this expression:
equals( toLower(outputs('Get_email_(V2)')?['body/from/emailAddress/address']), '[email protected]' )Important
Leave the No branch empty
Add all remaining steps inside the Yes branch
Step 5 - Add “Send an HTTP Request”
Inside the Yes branch:
Add a new action
Search for:
Send an HTTP request
Configure the action:
Field | Value |
Method |
|
URI | See below |
Content-Type |
|
URI
https://graph.microsoft.com/v1.0/me/messages?$filter=conversationId eq '@{outputs('Get_email_(V2)')?['body/conversationId']}'&$top=50&$select=id,subject,conversationId,receivedDateTimeThis step retrieves all emails belonging to the same conversation thread.
Shared Mailbox Alternative
If the above URI does not return the expected shared mailbox emails, use this version instead:
https://graph.microsoft.com/v1.0/users/[SHARED MAILBOX EMAIL ADDRESS]/messages?$filter=conversationId eq '@{outputs('Get_email_(V2)')?['body/conversationId']}'&$top=50&$select=id,subject,conversationId,receivedDateTimeStep 6 - Add “Parse JSON”
Still inside the Yes branch, add a new action and search for:
Parse JSON
For the Content field, select the body from the Send an HTTP request step.
For the Schema field, paste the following:
{
“type”: “object”,
“properties”: {
“value”: {
“type”: “array”,
“items”: {
“type”: “object”,
“properties”: {
“id”: {
“type”: “string”
},
“subject”: {
“type”: “string”
},
“conversationId”: {
“type”: “string”
},
“receivedDateTime”: {
“type”: “string”
}
}
}
}
}
}
This step allows Power Automate to use the email IDs returned from the HTTP request.
Step 7 - Add “Apply to each”
Add a new action
Search for:
Apply to each
For the input field, select:
value
(from the Parse JSON step)
This creates a loop through every email found in the conversation thread.
Step 8 - Add “Move email (V2)”
Inside the Apply to each step, add a new action and search for:
Move email (V2)
Configure it as follows:
Message Id: select id from the Parse JSON / Apply to each item
Folder: [DESTINATION FOLDER NAME]
Original Mailbox Address: [SHARED MAILBOX EMAIL ADDRESS]
This step moves each email in the conversation thread into the nominated folder.
Step 9 - Save and Test the Flow
Click Save
Send an email to Caresquare
Wait for a reply from [email protected]
Confirm the entire email thread moves to the nominated folder
Additional Testing
Also test with emails from other senders and confirm:
Those emails are not moved
The flow only applies to Caresquare replies
