How to send email using flow in salesforce

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

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 directlty using send email action.

Send Email Using Salesforce Flow

Send/Compose email directly using send email action.

  1. Go to Home then search for Flows.
  2. Click New flow to create new flow.
  3. Choose, Record Triggered flow.
  4. Then Choose Object, Opportunity.
  5. Configure Trigger, when A record is updated.
Record Triggered Flow
  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.
Flow Entry Criteria
Entry Criteria
Optimize flow for

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, lets create a body using new resource and make this as a dynamic.
    1. Hover in body, then click for 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 a 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.
New Action
New resource
Text Template new resource
Action email

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 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
Save the flow

Congratulation now we are done with our flow. Let’s take a look at it.

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.

Emaiil template

Once created email template, let’s create an email alert and will choose the above email template in the email alert.

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 Types.
  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.
email alert in flows

Now we are done with the email alert, let’s see what our final flow looks like.

send email using email alert in flows.

Output

Now let’s update an opportunity record and let’s see how its works.

Opportunity record update
Send Email Proof

In this post, we saw how we can send email using 2 different methods Also, see our 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.

Sharing Is Caring:

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

Leave a Comment