Hello Everyone in this post let’s understand how to send email using flow in salesforce using email alert, using send email core action, Also the summer 23 updates related to email.
If you are not followed our previous blog post feel free to check it out. Salesforce Lightning Tutorial For Beginners.
Table of Contents
Objectives
After reading this Blog you can able to understand how to use the ‘Send Email’ core action to send a formatted rich text email and how to use email alert to send email in salesforce using flows, also summer 23 updates.
Business Use Case
Send an email to the Opportunity owner when an opportunity is Closed-Won. The email template should include Opportunity details.
There are two ways to send an email using flows.
- Send email using standard email alert.
- Send/Compose email directly using send email action.
Send Email Using Salesforce Flow
1. Send/Compose Email Directly using send Email Action.
- Go to Home then search for Flows.
- Click New flow to create new flow.
- Choose, Record Triggered flow.
- Then Choose Object, Opportunity.
- Configure Trigger, when A record is updated.
- Choose entry Criteria.
- StageName Equal to Closed Won.
- StageName Is Changed {!$GlobalConstant.True}.
- Choose Optimize the Flow for:
- Actions and Related Records.
- The Click Save.
Now you are done with the entry criteria of our flow. So now let’s create an email action using flow.
- From the toolbox drag Action interaction to the screen/Canvas.
- Next in Action search for Send Email.
- Choose a label :- Send Email to Opportunity Owner.
- Api Name :- Send_Email_to_Opportunity_Owner.
- Description :- This action is to send an email to the Opportunity owner.
- In Input Values, lets create a body using new resource and make this as a dynamic.
- Hover in body, then click for new resource.
- Resource Type :- Text Template.
- API Name :- EmailTemplateBody.
- Body :- Good News!!. You woned the Opportunity you owned {!$Record.Name}.
- Please find the below details for your reference.
- Opportunity Amount : – {!$Record.Amount}.
- Opportunity Discount :- {!$Record.Amount_After_Discount__c}.
- Opportunity Account : – {!$Record.AccountId}.
- Then Click Done.
- Choose email action body as {!EmailTemplateBody}.
- Subject :- You just woned a Opportunity.
- Email Addresses (comma-separated) : –Choose Include.
- And Choose {!$Record.Owner.Email}.
- Rich-Text-Formatted Body :- Choose Include.
- And Choose {!$GlobalConstant.True}.
- Click Done.
Note: – If you do not set Rich Text formatted body to true, then you will receive an email with HTML tags.
Once you are done with the flow below method to connect and save the flow.
- Connect the flow from start to Action.
- Click Save.
- Enter Flow Label and 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
Congratulation now we are done with our flow. Let’s take a look at it.
2. Send Email Using Standard Email Alert
Let us take the same business use case here and achieve it using email alert using flows. To use email alert action in your flow follow the below steps.
To use email alert we should have an email template. so let’s create an email template as below.
Once created email template, let’s create an email alert and will choose the above email template in the email alert.
Once all prerequisites are completed, let’s see how to use this email alert in flow action.
- Drag action to the canvas.
- Then Choose filter by Types.
- Then in email alert choose the email alert you have created.
- Choose a label :- Send Email through email alert.
- In set input value choose Record ID: – {!$Record.Id}.
- Then click done.
Now we are done with the email alert, let’s see what our final flow looks like.
Output
Now let’s update an opportunity record and let’s see how its works.
3. Summer 23 Updates on Email Core Action
The Summer ’23 update of Salesforce brings significant enhancements is Salesforce Flow’s email core actions. Lets check out them.
Input Values
- Body: This is the body of the email. It is required if you are not using an email template. It is possible to type a text or create a text template (rich or plain text) and provide it as a resource.
- Email Template ID: This is the Id of the Classic or Lightning email template to use for the email subject and body.
- Log Email on Send: It is a boolean that indicates whether to log the email on the specified records’ activity timelines and activity history. To log an email, you must specify a value for Recipient Id, Related Record Id, or both.
- Recipient Address Collection: This is a text collection of the recipients’ email addresses. It is possible to enter a value for Recipient Id, Recipient Address List, and Recipient Address Collection as long as the total number of email addresses is five or fewer.
- Recipient Address List: This is a comma-delimited list of the recipients’ email addresses.
- Recipient ID: This is the Id of a lead, contact, or person account record. You must provide a value if you are using an Email Template. If Log Email on Send is true, this parameter becomes the Id of the person to send and log the email to. If there is an Email Template Id, this parameter is the Id of the person to send an email to and populate recipient merge fields with. If you enter a Lead Id, you can’t use Related Record Id.
- Related Record ID: This is the Id of a non-recipient record. For example, the Id of an opportunity record. If there is an email template, this parameter is the Id of the record for populating email template merge fields.
- Rich-Text-Formatted Body: This is a boolean that indicates whether you want the resource specified for the Body parameter to use rich text.
- Sender Email Address: It is the organization-wide email address for sending the email. It is required when Sender Type is OrgWideEmailAddress.
- Sender Type: Type of sender that the email is sent from. Valid values are CurrentUser (default value), DefaultWorkflowUser, and OrgWideEmailAddress.
- Subject: It is the subject of the email and it is required if you are not using an email template.
Note : Above input values credit goes to SalesforceTimes.com
Now we are using same business case, i.e, if Opportunity is won then send email to Opportunity owner. So as per that i added below input values in email core actions.
Output
Conclusion
In this post, we saw how we can send email using 2 different methods using flow. And also we saw what is changed in Summer 23 related to core email action.
Feel free to other blog post related to lightning. If you liked this blog post feel free to share it with your friends, until then we will meet you in another flow series blog post.
Good one…!
Nice post 🤩
Thank You.
Now I want to schedule it after one day like email is sent after one day of previous days all opportunities.
Hi Kinjal,
Could you please elaborate more?.