Skip to main content

Outlook - Automatically File Caresquare Ingest Replies

Two Outlook Power Automate setups — file successfully processed threads today, or file CS- status codes into separate folders once unsuccessful ingest replies are on.

This guide uses Microsoft Power Automate to file Caresquare replies out of the main inbox. Which flow you build depends on whether Caresquare has enabled unsuccessful ingest replies for your organisation.

  • Unsuccessful replies off (default today): you only receive a reply when an invoice is ingested. The body says Successfully processed. There is no CS-PROCESSED code. Use Section A.

  • Unsuccessful replies on: every outcome gets a reply. The first line is a status code (CS-PROCESSED, CS-DUPLICATE, CS-NON-INVOICE, or CS-FAILED). Use Section B.

If you are not sure which you have, look at a recent Caresquare reply. If the first line is a CS-… code, use Section B. If it only says Successfully processed, use Section A.

Both setups only act on emails from [email protected]. After the sender check, follow the matching section, then the shared thread-move steps.


Steps that are the same for both sections

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:

File Caresquare Invoice Threads
  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)” action

  1. Select + New step

  2. Search for Get email (V2)

  3. Select Message Id by typing / then selecting 'dynamic content' and by selecting message Id

  4. Configure the additional parameters:

Field

Value

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 "Condition" action to check the Sender

  1. Add a new step

  2. Select:

Condition (Control)

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 the body check from Section A or Section B inside the Yes branch

If you later turn unsuccessful replies on, keep this sender check and replace the Section A body check with the Section B nested checks.


Section A — Unsuccessful ingest replies are off

Use this section if Caresquare has not enabled unsuccessful ingest replies. You will not see CS-PROCESSED or any other CS-… code. Success replies only contain the text Successfully processed. Duplicates, non-invoices, and processing errors do not get a reply, so there is nothing extra to file.

This flow moves those success threads into Caresquare Processed, out of the main inbox.

Before you start — create one folder

In the shared mailbox, create:

  • Caresquare Processed

What this flow will do

When a new email arrives in a shared mailbox

Get email details

Check if the sender is Caresquare

Check the body for Successfully processed

Find all emails in the same conversation thread

Move each email to Caresquare Processed

Step 5A — Check the body for Successfully processed

Inside the sender Yes branch, add another Condition.

Use the expression editor:

contains(string(outputs('Get_email_(V2)')?['body/body']), 'Successfully processed')
  • Yes → follow the shared thread-move steps, and set the folder to Caresquare Processed

  • No → leave empty so the thread stays in the inbox

Then skip to the shared thread-move steps, then save and test using the Section A checks at the end of this article.


Section B — Unsuccessful ingest replies are on

Use this section only after Caresquare has enabled unsuccessful ingest replies for your organisation. In that mode, every outcome gets a reply, and the first line is a status code — including CS-PROCESSED on successful invoices. That code is not added until this option is turned on.

File each outcome in its own folder so staff work from the folders, not the main inbox:

First line

Meaning

Folder

CS-PROCESSED

The document was ingested as an invoice

Caresquare Processed

CS-DUPLICATE

Already in Caresquare

Caresquare Duplicate

CS-NON-INVOICE

Not processed as an invoice (a Reason: line follows)

Caresquare Non-Invoice

CS-FAILED

Could not be read, or a processing error

Caresquare Failed

The flow still accepts Successfully processed as a fallback so any older success replies (from before the option was turned on) are filed as processed.

Use Failed uploads in Caresquare for more detail on unsuccessful ingestions.

Before you start — create four folders

In the shared mailbox, create:

  • Caresquare Processed

  • Caresquare Duplicate

  • Caresquare Non-Invoice

  • Caresquare Failed

What this flow will do

When a new email arrives in a shared mailbox

Get email details

Check if the sender is Caresquare

Choose folder from CS-PROCESSED / CS-DUPLICATE / CS-NON-INVOICE / CS-FAILED

Find all emails in the same conversation thread

Move each email to that folder

Step 5B — Choose the destination folder from the status code

Inside the sender Yes branch, add nested Condition actions. Each Yes branch files the thread to a different folder. Each No branch goes to the next check.

Use the expression editor for each condition, in this order:

1. Processed

or(
contains(string(outputs('Get_email_(V2)')?['body/body']), 'CS-PROCESSED'),
contains(string(outputs('Get_email_(V2)')?['body/body']), 'Successfully processed')
)

Yes → destination folder Caresquare Processed

2. Duplicate (in the Processed No branch)

contains(string(outputs('Get_email_(V2)')?['body/body']), 'CS-DUPLICATE')

Yes → destination folder Caresquare Duplicate

3. Non-invoice (in the Duplicate No branch)

contains(string(outputs('Get_email_(V2)')?['body/body']), 'CS-NON-INVOICE')

Yes → destination folder Caresquare Non-Invoice

4. Failed (in the Non-invoice No branch)

contains(string(outputs('Get_email_(V2)')?['body/body']), 'CS-FAILED')

Yes → destination folder Caresquare Failed

If none of the codes match, leave the final No branch empty so the thread stays in the inbox.

In each Yes branch, add the shared thread-move steps, and set Move email to that branch’s folder.


Shared thread-move steps

Add these inside the matching Yes branch from Section A or Section B. For Section B, repeat them in each status-code Yes branch, changing only the folder.

Step 6 - Add “Send an HTTP Request” action

  1. Add a new action

  2. Search for:

Send an HTTP request (Outlook)
  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 7 - Add “Parse JSON”

Still inside the same 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 8 - Add “Apply to each” action

  1. Add a new action

  2. Search for:

Apply to each (Control)
  1. For the input field, select:

Body value

(from the Parse JSON step)

This creates a loop through every email found in the conversation thread.

Step 9 - Add “Move email (V2)” action

Inside the Apply to each step:

  1. Add a new action

  2. Search for Move email (V2)

Configure it as follows:

  • Message Id: select body id from the Parse JSON / Apply to each item

  • Folder: the folder for this branch (Section A: Caresquare Processed. Section B: Processed, Duplicate, Non-Invoice, or Failed)

  • Original Mailbox Address: [SHARED MAILBOX EMAIL ADDRESS]

For Section B, repeat Steps 6–9 in each status-code Yes branch, changing only the folder.

Step 10 - Save and Test the Flow

  1. Click Save

  2. Send an email to Caresquare

  3. Wait for a reply from [email protected]

Section A: confirm the whole thread moves to Caresquare Processed when the reply says Successfully processed.

Section B: confirm the whole thread moves to Caresquare Processed when the reply is CS-PROCESSED or Successfully processed. Confirm duplicates, non-invoices, and failures land in their own folders — not the main inbox.

Additional Testing

Also test with emails from other senders and confirm those emails are not moved.


Frequently Asked Questions

Which section should I use?

Open a recent reply from [email protected]. If the first line is CS-PROCESSED (or another CS-… code), use Section B. If the body only says Successfully processed, use Section A. CS-PROCESSED is not added until unsuccessful ingest replies are enabled.

Will this delete my emails?

No. Emails are only moved into a Caresquare folder. Open that folder to find them.

Can I undo this later?

Yes. Turn the flow off or delete it in Power Automate. You can move threads back to the inbox at any time.

Does this affect other emails?

No. The flow only continues when the sender is [email protected], and only if the body matches the Section A or Section B check.

What if we turn unsuccessful replies on later?

Create the extra folders (Duplicate, Non-Invoice, Failed). In the sender Yes branch, replace the single Successfully processed check with the nested Section B checks. Keep the existing thread-move steps for Processed, and copy them into each new Yes branch with the matching folder.

Did this answer your question?