Skip to main content

Automating Outlook Email Forwarding

Power Automate Guide — Move Caresquare Invoice Threads to a Folder

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:

  1. Check whether the email is from [email protected]

  2. If it is not, the flow stops

  3. If it is, the flow finds all emails in the same conversation thread

  4. 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

  1. Login

  2. Select Create

  3. Select Automated cloud flow

  4. Enter a flow name, for example:

Move Caresquare Invoice Threads to Folder
  1. Search for the trigger:

When a new email arrives in a shared mailbox (V2)
  1. Select the trigger

  2. Click Create


Step 2 - Configure the Shared Mailbox Trigger

In the trigger step:

  1. 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)”

  1. Select + New step

  2. Search for:

Get email (V2)
  1. Configure the action:

Field

Value

Message Id

Select Message Id from the trigger

Original Mailbox Address

[SHARED MAILBOX EMAIL ADDRESS]

Include Attachments

No

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

  1. Add a new step

  2. 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:

  1. Add a new action

  2. Search for:

Send an HTTP request
  1. Configure the action:

Field

Value

Method

GET

URI

See below

Content-Type

application/json

URI

https://graph.microsoft.com/v1.0/me/messages?$filter=conversationId eq '@{outputs('Get_email_(V2)')?['body/conversationId']}'&$top=50&$select=id,subject,conversationId,receivedDateTime

This 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,receivedDateTime

Step 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”

  1. Add a new action

  2. Search for:

Apply to each
  1. 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

  1. Click Save

  2. Send an email to Caresquare

  3. Wait for a reply from [email protected]

  1. 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

Did this answer your question?