How to send email using flow in salesforce

Hello Everyone in this post let’s understand how to send email using flow in salesforce using email alert, using send email core action, and 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.

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, as well as 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.

  1. Send email using standard email alert.
  2. Send/Compose email directly using the send email action.

Read the best salesforce Books: Click Here.

Send Email Using Salesforce Flow

1. Send/Compose Email Directly using Send Email Action.

  1. Go to Home then search for Flows.
  2. Click New Flow to create a new flow.
  3. Choose, Record Triggered flow.
  4. Then Choose the Object, Opportunity.
  5. Configure Trigger, when A record is updated.

Read the best salesforce Books: Click Here.

  1. Choose entry Criteria.
    1. StageName Equal to Closed Won.
    2. StageName Is Changed {!$GlobalConstant.True}.
  2. Choose Optimize the Flow for:
    1. Actions and Related Records.
  3. The Click Save.

Now you are done with the entry criteria of our flow. So now let’s create an email action using flow.

  1. From the toolbox drag Action interaction to the screen/Canvas.
  2. Next in Action search for Send Email.
    1. Choose a label:- Send Email to Opportunity Owner.
    2. Api Name:- Send_Email_to_Opportunity_Owner.
    3. Description:- This action is to send an email to the Opportunity owner.
  3. In Input Values, let’s create a body using a new resource and make this dynamic.
    1. Hover in the body, then click for a new resource.
    2. Resource Type:- Text Template.
    3. API Name:- EmailTemplateBody.
    4. Body:- Good News!!. You woned the Opportunity you owned {!$Record.Name}.
    5. Please find the below details for your reference.
    6. Opportunity Amount: – {!$Record.Amount}.
    7. Opportunity Discount:- {!$Record.Amount_After_Discount__c}.
    8. Opportunity Account: – {!$Record.AccountId}.
    9. Then Click Done.
  4. Choose email action body as {!EmailTemplateBody}.
  5. Subject:- You just woned an Opportunity.
  6. Email Addresses (comma-separated) : –Choose Include.
    1. And Choose {!$Record.Owner.Email}.
  7. Rich-Text-Formatted Body:- Choose Include.
    1. And Choose {!$GlobalConstant.True}.
  8. 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.

  1. Connect the flow from start to Action.
  2. Click Save.
  3. Enter the Flow Label and the API Name will auto-populate.
  4. Click Show Advanced.
  5. API Version for Running the Flow: 51
  6. Interview Label: Rich Text – Example {!$Flow.CurrentDateTime}
  7. Click Save

Congratulations 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 alerts using flows. To use email alert action in your flow follow the below steps.

To use email alerts 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 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.

  1. Drag action to the canvas.
  2. Then Choose filter by Type.
  3. Then in email alert choose the email alert you have created.
  4. Choose a label:- Send Email through email alert.
  5. In set input value choose Record ID: – {!$Record.Id}.
  6. 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 it 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. Let’s 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 a 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 the Sender Type is OrgWideEmailAddress.
  • Sender Type: The 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 the same business case, i.e., if Opportunity is won then send an email to Opportunity owner. So as per that, I added the below input values in email core actions.




Output

Conclusion

In this blog post, we learned how to send email using flow. If you have any doubts feel free to reach out.

In this post, we saw how we can send email using 2 different methods using flow. Also, we saw what has changed in Summer 23 related to core email action.

Related Quick Links

  1. Read the best salesforce Books: Click Here.
  2. HTTP Callout in Salesforce Flow Without Code [GET & POST]
  3. How to Invoke a Flow from a Lightning Web Component
  4. How to update child records using salesforce flow
  5. How to Assign records to Queue using Salesforce Flow?
  6. How to create a Data Table in Salesforce Flow : Complete Guide.
  7. How to retrieve record Type Id in flow
  8. How to navigate record detail page in flow
  9. How to send email using flow in salesforce
  10. How to Display Icon In Lightning Datatable
  11. How to Create Record in lightning Component
  12. How to Delete Multiple Records Using Checkbox In Lightning Component.

9 thoughts on “How to send email using flow in salesforce”

  1. I know this is an older post, but just to be clear if i want to send an email template to a customer they customer must exist as a Lead, Contact or Person account. I cannot use an email field?

    Reply

Leave a Comment