Send Rich Email with the new SendHTMLEmail Action

Note! This Action does not require Winter ’20 Functionality, but the Rich Text support in Text Templates and Automatic Output Handling inputs that are used in the explanation do require Winter ’20.

Video introduction

Installation (See bottom of post)

Source code

Flow provides a built-in Send Email action but it’s something of an underachiever. However, using the power of Apex and Flow Actions, its possible to build a powerful SendHTMLEmail action that can be easily installed and used from within Flow Builder. MVP Jeremiah Dohn pioneered this space several years back with his well received HTML Email Flow action. The version here is similar and adds a couple of additional capabilities.

This improved email experience provides:

Rich, HTML email bodies that can use all of the capabilities of Flow’s Text Templates, including Bold, Italics, Underline, Bullets and Numbers, Left/Center/Right justification, URLs, images, fonts, and text size:

This action also allows you to use Email Templates (both Classic and Lightning), so long as you provide it with a recordId to a Contact, Lead, or User that can be used to fill in the merge fields of the template:

To make it easy to pass email addresses into the action, it supports any combination of the following, for To, CC, and BCC:

  • A single email address
  • A string collection of email addresses
  • A collection of Contacts
  • A collection of Users
  • A collection of Leads

Other supported features include:

  • Ability to toggle on/off the use of the Salesforce per-user email signature
  • Ability to provide either a plain text body, an html body, or both
  • Ability to set the ReplyTo email address and the Sender Display Name


This sample flow ships with the action and can be used to test and demonstrate the action:

Here’s how I have my inputs configured in the above sample Flow for an HTML body from a Text Template:

Here’s how it would be configured for use with an Email Template. Note the plainTextBody, HTMLbody, and Subject are all nulled out (when “Don’t Include” is selected, null values are used):

You can use any of these five combinations:

  • An HTML Body
  • A plain text body
  • Both an HTML Body or a plain text body
  • A Classic Email Template
  • A Lightning Email Template

However, you’ll get errors if you try to mix your own bodies and subjects with Email Templates.

Using Templates

If you want to use an Email Template, you must pass in the Id (not the name) of the template. In the above flow example, I use a Get Record to query for an email template by name, and then pass in the ID to the SendHTMLEmail flow action. Importantly, you need to also pass in the recordId of a Contact, Lead, or User that will serve as the context record for the template and populate the template’s merge fields. Do this with the templateTargetObjectID parameter


This action makes use of the standard Salesforce email infrastructure, the same service that you use when you send a single email directly from a lightning experience page or a classic case feed. As such, any emails you send will be included in your usage, so be aware of the limits and guidelines. (Developer note: this action makes use of the Apex Messaging service API’s.)

This action does not use or involve Email Alerts, which are used in Workflow Rules and exist in Flow as separate actions you can drag into your flow. Be mindful of this so you don’t accidentally confuse the Email Alerts, the Email Templates, and the Flow Text Templates.

Currently unsupported features include:

  • Attachment support
  • Support for the MassEmailMessage API, enabling higher volumes
  • Character Set setting
  • OrgWideEmailAddress

If you’re interested in extending this class, please do so!


  • Install – Unmanaged (requires Winter ’20) (see note on installation at the bottom)
  • Install – Unmanaged (works with Summer ’19)
  • Install – Managed (requires Winter ’20)

This Flow Action doesn’t actually require Winter ’20 but it’s packaged with a test flow that does. Which was something of an oversight. So we’ve created a slightly different version of the test flow which doesn’t match the video exactly but doesn’t have the elements that require Winter ’20 (namely Automatic Output Handling innovations). Also, the rich text support that is highlighted here in Text Templates is a new addition to Winter ’20. If you’re not on Winter ’20 yet, however, you can still work with rich text email by using a Lightning Email Template.

Try to install the one that works best for you and leave a comment if you’re having problems.

2 replies
  1. Kou Xiong
    Kou Xiong says:


    Tried installing it and got this error:

    “The AppExchange Application or component you have selected is not yet available on your instance of Please check back in a few days to retry the installation. Press the back button of your browser now and bookmark the AppExchange Directory page so that you can find it later.”

    On NA57 instance.


Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply