This article explains how to use Salesforce Flow to automatically count the number of emails sent and received against a Case record. When an email is created on a Case (whether incoming or outgoing), a Record-Triggered Flow on the Email Message object increments a custom Number field on the related Case to maintain a running email count.
Test all steps in a Sandbox and thoroughly test before making changes in a Production environment.
This is an example use case that counts all incoming and outgoing emails. You can add additional conditions to the Flow logic to count only specific email types, such as incoming emails or draft emails.
| Field Label | Count of Emails |
| Length | 18 |
| Decimal Places | 0 |
| Description | This field is populated by a flow and counts the number of incoming and outgoing emails against a case |
| Help Text | Displays the count of emails related to the case |
| Default Value | 0 |
{!Get_Related_Case.Counts_of_Emails__c} + 1
000394643

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.