Last Updated on February 10, 2022 by Rakesh Gupta
Ever you want to use existing Salesforce HTML email templates to send an email from Salesforce Flow and don‘t know how to do it if the answer is yes then this article is for you. Salesforce allows you to use HTML email templates to create professional high-impact emails. It also allows you to use a letterhead with your company’s logo, branding, and use it across all your HTML email templates. Let’s start with a business use case
Objectives:
After reading this blog, you’ll be able to:
- How to create an Email Template and Email Alert
- Understand the process of using workflow email alert in Salesforce Flow
- Use Action in Flow to send HTML email
Business Use Case
Pamela Kline is a System Administrator at Gurukul on Cloud (GoC). She has received a requirement to create a one-click solution to update the case status to closed and also send out a confirmation email (Using HTML Email Template) to the customer.
Automation Champion Approach (I-do):
There are few solutions possible for the above business scenario, but we’ll use Flow to solve it. You can easily send an email from a process by using Send an email action. Email alerts are configured outside of the Process Builder and contain the standard text, list of recipients, and template for an email. In order to send an email using HTML email templates from a Flow, you must create the email alert first. Follow the below instructions to create a Flow and Email Alert to solve the above business requirement:
Step 1: Creating an Email Template
- Click Setup.
- In the User Interface, type Classic Email Templates.
- Clicks on the New Template button.
- Enter Email Template Name and select Classic Letterhead.
- Now enter the texts for the email message.
- Click Save
Step 2: Configuring Email Alert In Workflow Rule
- Click Setup.
- In the User Interface, type Email Alerts.
- Clicks on the New Email Alert button.
- Enter Short Description the Unique Name will auto-populate.
- Select the Case object from the dropdown list.
- Select the Email Template from the list.
- Make sure that you added Recipient Type to this email alert.
- Click Save.
Step 3: Create a Text Variable in the Flow
- Click Setup.
- In the Quick Find box, type Flows.
- Clicks on the New Flow button.
- Select the Screen Flow option and click on Create.
- Now create a Text Variable VarT_CaseID to store the Case ID (We will pass the Case record ID through custom button).
- Click Save.
Step 4: Add Update Records element
- Drag-and-drop Update Records element onto the Flow designer.
- Enter Label the API Name will auto-populate.
- To find the record select Specify conditions to identify records, and set fields individually option.
- Select the Case object from the dropdown list.
- Set Conditions
- Row 1:
- Field: ID
- Operator: Equals
- Value: {!VarT_CaseID}
- Row 1:
- Set Field Values:
- Field: Status
- Value: Closed
- Click Save.
Step 5: Add Action – Email Alert
- Drag-and-drop Action element on the Flow Designer.
- Search for Close Case Email Notification and select it.
- Enter Label the API Name will auto-populate.
- Set Input Values:
- RecordId: {!VarT_CaseID}
- Click Save.
In the end, Pamela’s Flow will look like the following screenshot
Almost there! Once everything looks good, click the Activate button. Make sure to copy Flow Unique URL.
Step 6: Call a Flow from a Custom button
We can call a Flow from the custom button, link, sub-flow, Visualforce page, Lightning Component, Apex start(), or using Process Builder.
- Click Setup.
- In the Object Manager, type Case.
- Clicks on the Buttons, Links, and Actions then click on the New Button or Link button.
- Enter Label the Name will auto-populate.
- For Display Type select Detail Page Button.
- To construct the URL you need Flow Unique URL, Variable Name. Create the URL as shown in the screenshot below
- Click Save
In the end, make sure to add the button Close Case custom button onto the Case Page Layouts.
It’s time to test this feature
Navigate to the Case tab, identify the Case, and click on Case Number.
Now I’m going to use the Close Case (Custom) button to update the case status to Closed, as shown in the following screenshot:

Note: – At run time, the email isn’t sent until the interview’s transaction completes. Transactions complete either when the interview finishes, executes a Screen element or executes a Wait element.
First of all thanks for this automation tutorial. I was utilizing the above use case but cannot able to use email alert in new version of Flow.
If I try to add Email using action it really does not provide option to import the email template created. Can you advise in this regard.
Hi Rakesh,
Can we trigger an email through Flow when a record is deleted?
Thanks,
Harsha
No, use Apex Trigger to achieve it.
Another option would be use Flow and then override delete button
Thank You for the quick response, Problem got fixed.
When I try to run the flow, Salesforce gives me this error: Please help!
“An unhandled fault has occurred in this flow
An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information.”
What could be a possible error?
Thank you very much
I also received email saying
FlowApplication
10:16 AM (1 hour ago)
to me
Error element Send_out_a_confirmation_email (FlowActionCall).
Missing required input parameter: SObjectRowId
Flow Details
Flow Name: Send_an_HTML_Email_From_Flow
Type: Autolaunched Flow
Version: 1
Status: Active
Org: Universal Container (00D41000002kAze)
Flow Interview Details
Interview Label: Send an HTML Email From Flow 2/7/2019 12:16 PM
Current User: Kajal Kantaria (00541000001dMqm)
Start time: 2/7/2019 12:16 PM
Duration: 0 seconds
How the Interview Started
Kajal Kantaria (00541000001dMqm) started the flow interview.
RECORD UPDATE: Update_Case_Status
Find all Case records where:
Id Equals {!VarTCaseID} ()
Update the records’ field values.
Status = Closed
Result
All records that meet the filter criteria are ready to be updated when the next Screen or Wait element is executed or when the interview finishes.
CASE.CLOSE_CASE_EMAIL (EMAIL ALERTS): Send_out_a_confirmation_email
Inputs:
SObjectRowId = {!VarTCaseID} ()
Error Occurred: Missing required input parameter: SObjectRowId
Looks like VarTCaseID field is not populated correctly
Great tutorial, quick question though. Can you pass anything else to the email template? Such as a specific To: email address or maybe a bulleted list that might have to be dynamic?
Yes, you can apply your logic to the email template.
Hello – thanks for the great tutorial.Is it possible to use a loop to collect a number of records and then email all of the records from the loop?
It is possible but currently Text Template doesn’t support HTML format outside Flow so it will not render properly in the email client.
If you want to display data in tabular format inside flow or salesforce yes it is 100% possible
Hello Rakesh,
I’ve followed this guide to create a simple flow wth only one Email Alert element.
This is the url for the button /flow/Invio_Email_Caso_Ecommerce?VarCaseID={!Case.Id}&Returl=/{!Case.Id}
I take the case ID from URL to put in the flow variable called “CaseID” and used like input on Email Alert element. as you described.
When I try to run the flow from the button in the case layout page, Salesforce gives me this error:
“An unhandled fault has occurred in this flow
An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information.”
What could be a possible error?
Thank you very much
There are numerous error
–> your URL should look like this
/flow/Invio_Email_Caso_Ecommerce?VarCaseID={!Case.Id}&retURL={!Case.Id}
–> You said, I take the case ID from URL to put in the flow variable called “CaseID”
In URL you are using VarCaseID and your flow varibale name is CaseID.
Make sure to use the correct variable name in custom button URL.
Great Rakesh! That was the errori. Thank you very much.
Now the flow send the email but I receive the same error when I click to finish button 🙁
Regards
You mean Flow is sending the email to recipients but you still getting the error.
If yes, could you please post complete error email here (Flow fault error email which is sent to the creator of the Process that is failing).
The flow is sending the email and show me the next step, that is a screen element with a Display text output where I wrote a confirmation message: “The Email message has been sent to the case owner”
I click finish and Salesforce shows me this error:
“An unhandled fault has occurred in this flow
An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information.”
Thank you very much for your help!
I need complete error email.
Check your email, you should receive fault error email (which is sent to the creator of the Flow/Process) from Salesforce.
I’m sorry!
Here you are:
Missing required input parameter: SObjectRowId
Inputs:
SObjectRowId = {!CaseID} ()
Error Occurred: Missing required input parameter: SObjectRowId
It means Flow is unable to pass the value to field SObjectRowId.
What you are trying to achieve?
Do one thing document your complete flow, upload it on GoogleDrvice and share the link here
Great explanation! Can you map other variables from the flow to the email alert or just fields?
Short and simple answer, only fields included on email template
Thank you for the tutorial Rakesh. What about if we need to send an email (with a Quote in PDF) in a Flow but filled with fields from 2 related objects (lookup relationship)? What would be the better solution?
The you have to use Apex class
Just desire to say your article is as amazing. The clarity on your put up is simply spectacular and i can think you are an expert in this subject.
Fine together with your permission let me to
seize your feed to stay up to date with coming near near post.
Thanks 1,000,000 and please carry on the gratifying
work.
Hi Rakesh, thank you for this tutorial! I have not yet build this solution but what I was wondering: the email that is send, will it show up in the Activity History? My experience with a Workflow triggered Email Alert is that it does not and thats a pity. Is that different when you trigger the email with help of a flow?
No it won’t