Last Updated on April 26, 2022 by Rakesh Gupta
Big Idea or Enduring Question:
Now (After Spring’21 Release), you can send rich-text Emails from Salesforce Flow using – Send Email core action! You read that right; so, continue to read on!
Salesforce now allows you to use Workflow Email Alerts (supports different Email templates) in the Salesforce Flow to send HTML Emails. There is one catch, however! – not every object supports Email Alert – such as EmailMessage and a few others.
Let us say you have to tackle, just like our friend Sergio Armendariz, the following use case: Send customers an Email at the end of a Flow by using Flow’s Send Email core action.
This article sheds light on how to send beautifully formatted rich text Emails from the Salesforce Flow.
Objectives:
After reading this blog, you’ll be able to:
- Create a Text Template in the Flow
- Use ‘Send Email’ core action to send a formatted rich text email
Business Use Case
Sergio Armendariz is an App Developer at Gurukul on Cloud (GoC). He received a requirement to enable users to type Email Content, Greetings, and Email address and then use send action to send out the Email.
Wait! That is not all! Sergio also wants to be able to add a .gif file via Email! Yep! Jazzing it up! Why not?
Sample Email:
Automation Champion Approach (I-do):
Salesforce now (After Spring’21 Release) allows you to send rich text Emails by using the Send Email core action. This is a major enhancement that will ultimately bring Flow to the next level.
There are few solutions possible for the above business scenario, but we’ll use Flow to solve it. Follow the instructions below to create a Flow and Email Alert to solve the above business requirement:
Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes to go through the following Flow diagram and understand it.
Let’s begin building this automation process.
Guided Practice (We-do):
There are 5 steps to solve Sergio’s business requirement using Salesforce Flow. We must:
- Upload a .gif file to document
- Define flow properties for screen flow
- Create a screen to capture the user data
- Add a screen element
- Add an email component
- Add a text component
- Add a body component
- Add a text Template to construct email body
- Add a core action send email to send out an email
Step 1: Upload a .gif File to Document
- In Salesforce Classic, click Document.
- Click New
- Make sure to select the Externally available Image option.
- Then uploads the .gif file and copy the link.
Step 2: Define Flow Properties
- Click Setup.
- In the Quick Find box, type Flows.
- Select Flows, then click New Flow.
- Select the Screen Flow option and click on Next and it will open the flow designer for you.
Step 3.1: Add a Screen Element
- Under Toolbox, select Elements. Drag and drop Screen onto the canvas.
- Input the following information:
- Enter Label the API Name will auto-populate.
- Click Done.
Step 3.2: Add an Email Component to capture Recipient Email Address
- Under Input section on Screen Element. Drag and drop Email onto the screen.
- Input the following information:
- Field API Name: RecipientEmail
- Label: Recipient Email
- Required: {!$GlobalConstant.True}
- Click Done.
Step 3.3: Add a Text Component to Capture the First Name
- Under Input section on Screen Element. Drag and drop a Text onto the screen.
- Input the following information:
- Label: First Name
- API Name: First_Name
- Require: Checked
- Click Done.
Step 3.4: Add a Long Text Area Component to Capture the Email Body
- Under Input section on Screen Element. Drag and drop Long Text Area onto the screen.
- Input the following information:
- Label: Email Body
- API Name: Email_Body
- Require: Checked
- Click Done.
Step 4: Add a Text Template to Construct Email Body
Now we’ll create an email template using the Text Template. Text template allowed you to specify the multi-line messages. It also allows you to use HTML code.
- Under Toolbox, select Manager, then click New Resource to create a text template.
- Input the following information:
- Click Done.
Step 5: Add Send Email Core Action to Send Out an Email
Now we will use the Send Email static action to send out an e-mail to Recipient.
- Under Toolbox, select Element.
- Drag-and-drop Action element onto the Flow designer.
- Select send Email out-of-the-box action.
- Enter a name in the Label field; the API Name will auto-populate.
- Set Input Values
- Body: {!ttEmailBody}
- Subject: Thanks for Attending Automation Champion Office Hour
- Email Addresses (comma-separated): {!RecipientEmail.value}
- Rich-Text Formatted Body: {!$GlobalConstant.True}
- Click Done.
In the end, Sergio’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: 51
- Interview Label: Rich Text – Example {!$Flow.CurrentDateTime}
- Click Save.
Feel free to add this Flow to the Lightning Home page or Lightning Record Page. I’ve added the Flow on the Lightning Home page for the Sales Application.
Proof of Concept
Email Output without Enabling Rich-Text-Formatted Body
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?
Let me know by Tweeting me at @automationchamp, or find me on LinkedIn.
I followed as it is, but output not coming
Can you provide a screenshot of what you’re seeing?
Great Post. I tried this a few weeks ago and ran into a few quirks that i want to share.
1.
Can we include the complete record url in the email we send from the flow?
How can I give only one line break with the body content
This is an extremely well-written post.Thank you.
But how do I get access to an org with Spring ’21. I thought that was not available until February at the earliest?
Great to hear from you! Very much appreciated 🙏
For Spring’21 pre-release org, you have to wait few more hours (until 10th Dec 2020). On December 10th sign-up for pre-release org using this URL sfdc.co/RR-Pre-Release