Last Updated on June 10, 2022 by Rakesh Gupta
Big Idea or Enduring Question:
- How can you automatically update the case status when receives a response from customers via Email-to-Case?
Objectives:
This blog post will help us to understand the following
- Understand how email-to-case works
- Create a flow that fires on the customer’s response to an email-to-case
- Use decision element to validate the data
- Use the update records element to open a closed case
Business Use Case
Pamela Kline is working as a System administrator at Universal Containers (UC). She has just implemented an email-to-case process. Now she has received the following enhancements from the support agent:
- Automatically add customer response to the case email thread, when the customer replies to the email that has been sent from a case.
- Re-open a case when the customer responds to a support agent email, within five days of case closure.
Automation Champion Approach (I-do):
Email-to-Case allows you to create a case automatically when a customer emails in. It also populates some key information, for example, the email subject becomes the case subject, and the email body-mapped to the description. You can configure multiple Email-to-Case channels based on your business use case.
Next, you have to understand the Thread ID. The thread ID is a unique ID generated for outbound emails within the case. The thread ID will look like ref:_00D90wAtk._500901Kc5WN:re. To automatically add customer responses to the case email thread, make sure that Email-to-Case has been configured correctly for customer email responses to be attached to the case.
- Email Threading is an important part of the Email-to-Case setup. Setting this up essentially means that, if a customer emails you more information about an existing Case, their second email will be attached to their existing Case instead of creating a new Case. If you want to auto add a unique Thread ID into your auto-responses and other outgoing emails, then navigate to Setup | Feature Settings | Service | Email-to-Case and select the check-boxes as shown in the following screenshot
- When you are replying to a customer make sure to change the address from the Owner to the Email to the Case support address. If this is not changed, then the response from the customer will be sent to the owner of the case and will not be added to the Email Thread. Follow the below steps to add Email-to-Case support address to from address (Basically we are going to add Email-to-Case support address to Organization-Wide Addresses:

- Copy the Email Services Address (i.e. Long email address) from Email-to-Case as shown in the preceding screenshot.
- The next step is to add a new Organization-Wide Email Addresses. Use Email Services Address (Long address) in place of Email Address, as shown in the following screenshot:

- For verification purposes, Salesforce will send an email notification with a confirmation link to the above-mentioned email address
- As we are using an Email-to-Case routing address, it will automatically create a case in your org, from where you can verify the ownership of the email address.

- Click on the link mentioned under the description to verify the Organization-Wide Address. After successful verification, you can use the Email-to-Case Support address to send out an email from Salesforce.
Sample Output
Solution for Use Case – 2
Our next task is to create a Flow on the Email Message to execute, only when an email message is received and re-open a case when the customer responds to a support agent email, within five days of case closure.
To solve this requirement, we will use the After-save Record-Triggered Flow. Check out this article to understand why we are using after-save record-triggered flow for this scenario.
Let’s take a pause here, familiarize yourself with the EmailMessage objects in Salesforce.
Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes going through the following Flow diagram and understand it.
Let’s begin building this automation process.
Guided Practice (We-do):
There are 4 steps to solve Pamela’s business requirement using Record-Triggered Flow. We must:
- Define flow properties for record-triggered flow
- Formula to calculate the number of days between the close date and today
- Add a decision element to check the case status and number of days formula
- Add an update records element to re-open a case
Step 1: Define Flow Properties
- Click Setup.
- In the Quick Find box, type Flows.
- Select Flows then click on the New Flow.
- Select the Record-Triggered Flow option, click on Create and configure the flow as follows:
- Object: EmailMessage
- Trigger the Flow When: A record is created
- Set Entry Criteria
- Condition Requirements: None
- Optimize the Flow For Action and Related Records
- Click Done.
Step 2: Formula to Calculate the Number of Days Between Close Date and Today
- Under Toolbox, select Manager, then click New Resource to calculate the number of days between case close date and today.
- Input the following information:
- Resource Type: Formula
- API Name: forN_DaysSinceCaseClosed
- Data Type: Number
- Decimal Places: 0
- Formula: {!$Flow.CurrentDate} – DATEVALUE({!$Record.Parent.ClosedDate})
- Click Done.
Step 3: Using Decision Element to Check Case Status and Number of Days Formula
Now we will use the Decision element to check the case status and the number of days formula.
- On Flow Designer, click on the +icon and select the Decision element.
- Enter a name in the Label field; the API Name will auto-populate.
- Under Outcome Details, enter the Label the API Name will auto-populate.
- Condition Requirements to Execute Outcome: All Conditions Are Met (AND)
- Row 1:
- Resource: {!$Record.Parent.Status}
- Operator: Equals
- Value: Closed
- Add Condition
- Row 2
- Resource: {!$Record.Incoming}
- Operator: Equals
- Value: {!$GlobalConstant.True}
- Add Condition
- Row 3
- Resource: {!forN_DaysSinceCaseClosed}
- Operator: Less Than or Equal
- Value: 5
- Row 1:
- Click Done.

Step 4: Add Action – Update Records
The next step is to update the case status to re-open. We will use the Update Records element.
- On Flow Designer, below the Recently Closed Cases node, click on the +icon and select the Update Records element.
- Enter a name in the Label field; the API Name will auto-populate.
- Click Specify conditions to identify records, and set fields individually
- Object: Case
- Select All Conditions Are Met (AND).
- Set Filter Conditions
- Row 1:
- Field: Id
- Operator: Equals
- Value: {!$Record.ParentId}
- Row 1:
- Set Field Values for the Case Records
- Row 1:
- Field: Status
- Value: Working
- Row 1:
- Click Done.
In the end, Pamela’s Flow will look like the following screenshot:
Once everything looks good, perform the steps below:
- Click Save.
- Enter Flow Label the API Name will auto-populate.
- Click Show Advanced.
- API Version for Running the Flow: 54
- Interview Label: Reopen Closed Case {!$Flow.CurrentDateTime}
- Click Save.
Almost there! Once everything looks good, click the Activate button.
Formative Assessment:
I want to hear from you!
What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? Feel free to share in the comments below.









Hi buddy, i am not able to put the email-to-case’s email service address in org wide email address. i am getting below error- Error: Invalid Email Address: Must be in domain(s)
Salesforce Security has restricted the use of domain “apex.salesforce.com”.
The domain cannot be used as customer’s sending addresses, including service addresses. The solution for this is to use your the customer’s own domain email addresses rather than salesforce domain addresses.
Hi Rakesh Sir- Now the Case Status is ‘Working’. I want to add another status that says Reopen case replied or Reply/Reopen Case, once a customer is replying to the ‘Working’ Case. How to Achieve that?
Here you go:
1. Have an automation on EmailMessage
2. Check the case status = Working
3. If yes, then update the case status to “Reopen case replied or Reply/Reopen Case”
We use a Status called ‘Pending with Customer’ we have several SLAs which look at the amount of time that has lapsed to the current time. The intention of the status was that it would ’pause the clock’ and then resume once a status change occurs.
Status called ‘Pending with Customer’ shall stop calculating the case SLA. How can I achieve this?
When you use Entitlement & Milestones, Case object will have an field called Stopped (API: IsStopped). You can make it as true to stop milestone.
Hi Rakesh, We have set up Email-to-Case for two routing addresses. service@xyz.com (a new case is created with Record type Z) & fieldservice@xyz.com (a new case is created with record type S). We use case feed from case (Record type Z ) to send an email internally to other department. A Case creation with two different record types seems to be working fine.
In following two scenarios a new case (Record Type S) is not generated,
1. If the person replies to the email from case feed of Record Type Z & adds routing email address – fieldservice@xyz.com, it appears only in the case feed of other Record type Z, as the reply contains Thread ID.
2. If we send an Email directly from case feed of case (Record Type Z) to the other routing address fieldservice@xyz.com, then also a new case (Record type S ) not created, only sent email appears in the case feed of the Record type Z.
Thanks in advance,
Best Regards,
Suhas
Thank you so much .. it’s worked
Thank you for saving me 45 minutes trying to figure this out. I was able to get this working quickly. Thanks for the clear wording and instructions, the Trailhead writers could learn a thing or two from you~
I didn’t have any expectations concerning that title, but the more I was astonished. The author did a great job. I spent a few minutes reading and checking the facts. Everything is very clear and understandable. I like posts that fill in your knowledge gaps. This one is of the sort.
Hi Rakesh,
First, thank you for this solution.
When I debug, it is working as expected as per log. But when emailed to test, the case status is not updated from closed to open.
Can you screenshot the relevant section of the debug log and Flow? This sounds weird.
Thanks for this great post. But i’m facing the following issue. Out requirements are little bit different but also ends with an update on the case. When the customer replies to an email the Case status is waiting on reply. The flow should update the case status to In progress. This happens, but a few seconds later Salesforce overwrites this status with New Email… How can we prevent that from happening?
Better to add additional logic to your flow, preventing Salesforce from overwriting the status with the new email.
I didn’t see Nige’s answer to the flow not accepting the formula but solved it as follows.
I created two new formula resources of type Date
and stored the two dates.
The formula then became
{!forCurrentDate} – {!forClosedDate}
which worked.
And I couldn’t debug it as I couldn’t select an email to test it on.
So I used an email alert while debugging.
For anyone getting the same error as Debra S. just remove the – symbol from the forumla and replace it with the subtract symbol on your keyboard or via the operator menu in the formula and the syntax passes 😀
What would be the solution to reopen closed case on a new email in the world where the Case Thread ID has been deprecated? The use case I have is, case is closed, an automation sends an email informing the case requestor the case is closed. If the customer replies to that email, there is neither Thread ID nor Header information that will associate the new reply on a case to the original one. Is there a workaround without using custom code? Thank you.
Hi Rakesh,
I’m getting a syntax error with the formula, {!$Flow.CurrentDate} – DATEVALUE({!$Record.Parent.ClosedDate}), stating the formula expression is invalid. Where might I have gone wrong? My formula looks just like your image.
Please let me know if you’re still facing the issue.
Hello, I tried this, but its not working.Its showing FIELD_CUSTOM_VALIDATION_EXCEPTION. Please help
Check custom validations on case object
what if it is after the 5 days and you do not want to open the existing case. Are you just ignoring the communication from the client? I think there needs to be followup and create a new case (clone the existing?). How do you get this reply to be associated to the newly created case.
Feel free to modify the flow as per your business requirement. In such a scenario, create a case and update the EmailMessage record to point t the new case.
This post was really helpful .It worked well !!!
Thankyou so much for this 🙂
Thank you!
Thanks so much for this. I did not even realize there was an object called email message. I was able to implement this base flow with tweaks to address a pain point within a company’s process. Thanks again.
Great to hear Neil! Glad it was helpful!
Thanks for the article on Update the Case Status Through Email-to-Case Response.Looking forward for more articles like this.
Any suggestions so that when users originally CC’d on a case reply to a case a new Case does not get created? There does not seem to be a way to setup auto-response to also go to users that are CC’d so that they also get the thread id in the reply.
Actually – I guess I now see the “Case Auto-Response Rules” settings. (I only find answers to problems right after posting.. even if after searching for long periods. ha) Will test to confirm…
I did exactly what you list above and it’s not working. Any suggestions?
Please verify the steps once again
Nope, still not working. I have done this 5 times from scratch and it’s not working. I am using the Professional Edition.
Send me complete details with the screenshot at info@automationchampion.com
I am trying to follow the process builder steps but I don’t have [EmailMessage].Parent.Status and I need to indicate in the criteria that the case has to be closed to start the process. Is there another way to proceed?
Thank you, the article is very clear and easy to follow 🙂
Please check Field level security
Good one
This is a great use case! Is there a way to test this out in a Sandbox I wonder? I don’t know of a way to turn on temporary email delivery within the sandbox. Any suggestions would be appreciated.
*Bailey Rudd * Sales Operations | CRM Administrator
Change the Email Deliverability to All Email from No access. Please refer this article for details instructions https://help.salesforce.com/HTViewHelpDoc?id=emailadmin_deliverability.htm