Effortless Automation: Email Notifications for Salesforce Cases via Email-to-Case, Flow, and Email Templates

Himanshu Varshney
Senior Salesforce Developer
December 15, 2023

SalesforceEmailFlowsBlog

Create an Email Template:

In Salesforce, navigate to Setup. In the Quick Find box, enter "Classic Email Templates" or "Lightning Email Templates" based on your Salesforce version. Create a new Email Template or use an existing one that suits your notification requirements.


Create a Flow:

Go to Setup.

In the Quick Find box, enter "Flows" and select "Flows."

Create a new Flow by clicking on "New Flow."

Use the Flow Designer to build your flow. Here's a simplified example of a flow that sends an email notification:

+---------------------+
| Start               |
| (Record Trigger)   |
+---------------------+
         |
         V
+---------------------+
| Record Lookup       |
| (Lookup Case)       |
+---------------------+
         |
         V
+---------------------+
| Decision            |
| (Is Case Found?)    |
+---------------------+
|                     |
| Yes                 | No
|                     |
V                     V
+---------------------+        +-----------------------+
| Send Email          |--------| Create Case Record   |
| (Use Email Template)|        |                       |
+---------------------+        +-----------------------+

The Flow should start with a Record Trigger for the Case object.

Add a Record Lookup to check if the case already exists (using criteria like Email Subject, etc.).

Use a Decision element to check if the case was found.

If the case is found, proceed to the Send Email element, using the Email Template you created.


Activate the Flow:

Once you've created and tested your Flow, activate it. Configure Email-to-Case:

In Salesforce, navigate to Setup. In the Quick Find box, enter "Email-to-Case." Configure your Email-to-Case settings to use the Flow you created for the "On Create" trigger.


Test:

Create a test case by sending an email to your designated Email-to-Case email address. Ensure that the email creates a new case and triggers the Flow. Here's an example code snippet for sending an email in the Flow. Note that the actual code may vary based on your specific requirements and the complexity of your email template:

// Apex Class for sending an email in Flow
public class FlowEmailNotification {

    // Method to send email using the specified email template
    public static void sendEmailNotification(Id caseId, Id emailTemplateId) {
        // Load the case record
        Case myCase = [SELECT Id, Subject, Description, ... FROM Case WHERE Id = :caseId LIMIT 1];

        // Load the email template
        EmailTemplate emailTemplate = [SELECT Id, Subject, HtmlValue, Body FROM EmailTemplate WHERE Id = :emailTemplateId LIMIT 1];

        // Create an Email Message
        Messaging.SingleEmailMessage emailMessage = new Messaging.SingleEmailMessage();
        emailMessage.setSubject(emailTemplate.Subject);
        emailMessage.setHtmlBody(emailTemplate.HtmlValue);
        emailMessage.setPlainTextBody(emailTemplate.Body);
        emailMessage.setToAddresses(new String[] { 'recipient@example.com' }); // Replace with the recipient's email address

        // Attach the case information to the email
        emailMessage.setWhatId(myCase.Id);

        // Send the email
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { emailMessage });
    }
}

In your Flow, you would use an "Apex Action" to invoke this Apex class and pass the necessary parameters such as the caseId and emailTemplateId.

Remember to adapt the code to your specific requirements, including handling errors and customizing the email content based on your Email Template structure. Additionally, ensure that your Salesforce user has the necessary permissions to execute Apex and send emails.


Now, for the second part, we will send an email notification whenever a case is resolved via Email-to-Case in Salesforce using Flow and an Email Template. You can follow a similar approach as mentioned before. However, this time, you'll need to trigger the Flow when the case is resolved. Here's a step-by-step guide:


Create an Email Template:

In Salesforce, navigate to Setup. In the Quick Find box, enter "Classic Email Templates" or "Lightning Email Templates" based on your Salesforce version. Create a new Email Template or use an existing one for the resolution notification.


Create a Flow:

Go to Setup.

In the Quick Find box, enter "Flows" and select "Flows."

Create a new Flow by clicking on "New Flow."

Use the Flow Designer to build your flow. Here's a simplified example of a flow that sends an email notification when a case is resolved:

+---------------------+
| Start               |
| (Record Trigger)   |
+---------------------+
         |
         V
+---------------------+
| Record Lookup       |
| (Lookup Case)       |
+---------------------+
         |
         V
+---------------------+
| Decision            |
| (Is Case Resolved?) |
+---------------------+
|                     |
| Yes                 | No
|                     |
V                     V
+---------------------+        +-----------------------+
| Send Email          |--------| Update Case (Optional)|
| (Use Email Template)|        |                       |
+---------------------+        +-----------------------+

The Flow should start with a Record Trigger for the Case object.

Add a Record Lookup to check if the case is resolved (use the status field or any custom field that indicates resolution).

Use a Decision element to check if the case is resolved.

If the case is resolved, proceed to the Send Email element, using the Email Template you created.

Optionally, you can add an Update Case element to update the case record, such as setting a "Notification Sent" flag.


Activate the Flow:

Once you've created and tested your Flow, activate it. Configure Email-to-Case:

In Salesforce, navigate to Setup. In the Quick Find box, enter "Email-to-Case." Configure your Email-to-Case settings to use the Flow you created for the "On Case Resolution" trigger.

Test:

Resolve a test case either manually or through your Email-to-Case process. Ensure that the resolution triggers the Flow and the email notification is sent.

For the code snippet, you can use a similar Apex class as before with a method tailored for the resolution notification. Here's an example:

// Apex Class for sending an email on case resolution in Flow
public class FlowEmailOnResolution {

    // Method to send email notification on case resolution
    public static void sendResolutionNotification(Id caseId, Id emailTemplateId) {
        // Load the case record
        Case myCase = [SELECT Id, Subject, Description, ... FROM Case WHERE Id = :caseId LIMIT 1];

        // Load the email template
        EmailTemplate emailTemplate = [SELECT Id, Subject, HtmlValue, Body FROM EmailTemplate WHERE Id = :emailTemplateId LIMIT 1];

        // Create an Email Message
        Messaging.SingleEmailMessage emailMessage = new Messaging.SingleEmailMessage();
        emailMessage.setSubject(emailTemplate.Subject);
        emailMessage.setHtmlBody(emailTemplate.HtmlValue);
        emailMessage.setPlainTextBody(emailTemplate.Body);
        emailMessage.setToAddresses(new String[] { 'recipient@example.com' }); // Replace with the recipient's email address

        // Attach the case information to the email
        emailMessage.setWhatId(myCase.Id);

        // Send the email
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { emailMessage });
    }
}

As before, you would use an "Apex Action" in your Flow to invoke this Apex class and pass the necessary parameters such as the caseId and emailTemplateId. Customize the code based on your specific requirements and the structure of your Email Template.

Share this article:
View all articles

Related Articles

Choosing the Right Data Sources for Training AI Chatbots featured image
December 12, 2025
If your AI chatbot sounds generic, gives wrong answers, or feels unreliable, the problem is probably not the model. It is the data behind it. In this article, you will see why choosing the right data sources matters more than any tool or framework. We walk through what data your chatbot should actually learn from, which sources help it sound accurate and confident, which ones quietly break performance, and how to use your existing knowledge without creating constant maintenance work. If you want a chatbot that truly reflects how your business works, this is where you need to start.
Lead Qualification Made Easy with AI Voice Assistants featured image
December 11, 2025
If your sales team is spending hours chasing leads that never convert, this is for you. Most businesses do not have a lead problem, they have a qualification problem. In this article, you will see how AI voice assistants handle the first conversation, ask the right questions, and surface only the leads worth your team’s time. You will learn how voice AI actually works, where it fits into real sales workflows, and why companies using it respond faster, close more deals, and stop wasting effort on unqualified prospects. If you want your leads filtered before they ever reach sales, keep reading.
The Automation Impact on Response Time and Conversions Is Bigger Than Most Businesses Realize featured image
December 9, 2025
This blog explains how response time has become one of the strongest predictors of conversions and why most businesses lose revenue not from poor marketing, but from slow follow up. It highlights how automation eliminates the delays that humans cannot avoid, ensuring immediate engagement across chat, voice, and form submissions. The post shows how automated systems capture intent at its peak, create consistent customer experiences, and significantly increase conversion rates by closing the gap between inquiry and response. Automation does not just improve speed. It transforms how the entire pipeline operates.

Unlock the Full Power of AI-Driven Transformation

Schedule a Demo

See how Anablock can automate and scale your business with AI.

Book Now

Start a Voice Call

Talk directly with our AI experts and get real-time guidance.

Call Now

Send us a Message

Summarize this page content with AI