Send Rich Email (Send HTML Email Action)

Note: There’s a version of this action that uses a Custom Property Editor to provide a more usable configuration experience. It requires a Spring ’20 Org that has been activated for the Custom Property Editor Pilot. Learn more here.

Video introduction

Installation (See bottom of page)

Source code

Flow provides a built-in Send Email action but it’s something of an underachiever. The sendHTMLEmail action uses the power of Apex and Flow Actions, 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 several of additional capabilities.

This improved email flow action supports:

  • 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
  • Email Templates (both Classic and Lightning) with field merge and letterheads
  • 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
  • Organization-Wide Email Addresses
  • Attachments
  • Ability to toggle on/off the use of the Salesforce per-user email signature
  • Ability to provide a plain text body, an html body, or both
  • Ability to set the ReplyTo email address and the Sender Display Name
  • Multi-Language Support for Lightning Email Templates

Each email requires several components, but they may be constructed in many ways using the component parameters. The package includes a flow that produces emails in several scenarios. See Examples below.

Currently unsupported features include:

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

NOTE: Scratch orgs have a strict cutoff after sending just 50 email messages

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

Composing an EMail

There are many configurable options for this Action Component. Decide what and how your email needs to communicate, then choose the best combination to provide the needed communication.

Other Features

Each email requires several components, but they may be constructed in many ways using the component parameters. Illustrated examples here include:

  1. Simple Email Text – with To, Sender, Reply-To, Subject, Body (All text)
  2. Simple Email with Address Collections – Using Address Collections to Send to Multiple Recipients
  3. Email with Attachments – Simple Email (1) With Attachments
  4. Email Using Template – An email using a Lightning EmailTemplate
  5. Multi-Lingual Using Email Templates – An email using a Lightning EmailTemplate selected by language

Addresses (To, CC, BCC)

All emails must be addressed to users or entities conforming to RFC 5322, 3.4. guidelines. More plainly, they must be sen using or more standard email addresses (e.g. john.smith@example.com or “John Smith”<john.smith@example.com>). This component creates addresses in the following ways (or a combination of any/all of these ways):

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

Pass address(es), you need to create and populate the string or collection in Flow or in Apex:

Create Flow Variable:

Addresses (To, CC, BCC ) Examples

This image has an empty alt attribute; its file name is CreateCollectionVariable.png
Add a collection variable
This image has an empty alt attribute; its file name is PopulateCollectionVariable.png
Populate the collection variable
This image has an empty alt attribute; its file name is image-3.png

Addresses (To, CC, BCC ) Reference

Addressees are manually assigned using the following parameters (Type List<> is a Collection):

Name Type
SendTOthisOneEmailAddressString
SendTOthisStringCollectionOfEmailAddressesList<String> (or Collection of String in Flow)
SendTOtheEmailAddressesFromThisCollectionOfContactsList<Contact> (or Collection of Contact in Flow)
SendTOtheEmailAddressesFromThisCollectionOfUsersList<User> (or Collection of User in Flow)
SendTOtheEmailAddressesFromThisCollectionOfLeadsList<Lead> (or Collection of Lead in Flow)
SendCCthisOneEmailAddressString
SendCCthisStringCollectionOfEmailAddressesList<String> (or Collection of String in Flow)
SendCCtheEmailAddressesFromThisCollectionOfContactsList<Contact> (or Collection of Contact in Flow)
SendCCtheEmailAddressesFromThisCollectionOfUsersList<Lead> (or Collection of Lead in Flow)
SendBCCthisOneEmailAddressString (or Collection of String in Flow)
SendBCCthisStringCollectionOfEmailAddressesList<String> (or Collection of String in Flow)
SendBCCtheEmailAddressesFromThisCollectionOfContactsList<Contact> (or Collection of Contact in Flow)
SendBCCtheEmailAddressesFromThisCollectionOfUsersList<User> (or Collection of User in Flow)
SendBCCtheEmailAddressesFromThisCollectionOfLeadsList<Lead> (or Collection of Lead in Flow)

Sender (From)/Reply-To

Sender/Reply-To determine what addresses the email will appear to be coming from. NOTE: Unless you’ve made special arrangements in your Org, the message will always appear to be coming from (Example): noreply@salesforce.com; on behalf of; Do Not Reply <donotreply.example.com> .

You can either 1) use an OrganizationWideEmailAddress or 2) specify your own Reply-To Email Address and Sender Display Name. If you provide an OrganizationWideEmailAddress, that will take precedence and any Reply-To Email Address and/or Sender Display Name you’ve also provided will be ignored.

Sender (From)/Reply-To Using Organization-Wide Email Address

To use an OrganizationWideEmailAddress , pass the Id of one that you have defined into the action via the “Use This Organization-Wide Email Address Id”. (If you want to get the benefit of Verified sending, you can’t just paste the email address into the Reply-To Email Address field. You have to use the Use This Organization-Wide Email Address Id field.). to find the ID, search the OrgWideEmailAddress object for the appropriate Id. NOTE: you cannot use OrganizationWideEmailAddress and

  1. In Lightning Setup, go to Organization-Wide Addresses and click Edit on the address you want to use:
This image has an empty alt attribute; its file name is image-1.png

2. Examine the URL of this web page. It should look something like this:

https://connect-dream-4759-dev-ed.lightning.force.com/lightning/setup/OrgWideEmailAddresses/page?address=%2F0D2560000008PGP%2Fe

3. The Id of the Organization-Wide Email Address is the character between the 2 “%2F” strings. So in the example above, you would extract “0D2560000008PGP” and insert it as an input:

This image has an empty alt attribute; its file name is image-2.png

Sender (From)/Reply-To Using Organization-Wide Email Address Reference

NAMETYPE
orgWideEmailAddressIdString

Sender (From)/Reply-To Using Custom Reply-To and/or Sender Display Name

You can change both the “Reply-To” and how you wish that name to be displayed.

The optional In-Reply-To field of the outgoing email identifies the email or emails to which this email is a reply (parent emails) , and the name that appears on the From line of the email. The display name cannot be set if the object associated with a setOrgWideEmailAddressId has defined its DisplayName field.

Sender (From)/Reply-To Using Custom Reply-To and/or Sender Display Name Reference

NAMETYPE
replyEmailAddressString
senderDisplayNameString

Subject

Many mail servers require a subject for delivery from the assumption that if you don’t have a subject line, it is a spam email message. However, be aware that the subject is NOT an encrypted part of an email transmission and is visible (open text) when transmitted (in many cases). Subject can be set in two ways:

  1. Assign text to the subject parameter. You can assign any text you want to this field EXCEPT if you are using an Email Template to create the message. If you are using a an EmailTemplate, do not specify this field because it will result in an exception. Templates create their own Subject, Body and other parts and cannot be overridden from the Flow Action.
  2. Assign the Subject in a template to construct the subject field and use the template as specified below. Refer to Configure an Email Letterhead and Template for configuring a template.

NOTE: If you specify Subject when using an Email Template, that value will override the Template’s Specified Subject. Emails without a subject (either specified or part of the template) will not be sent/delivered.

Subject Reference

NAMETYPE
subjectString

Body

To specify the body of the email, you can use any of these combinations :

  1. HTML Body. The body is composed using a text (or rich text) variable, then passed to the Action in the HTMLbody parameter. Flow variables and Global variables can be included for merge in the text at the time of invocation using the standard merge syntax (e.g., {!stringCollectionEmailAddresses} ). You cannot use HTMLBody and a template.
    1. Advantages. Very quick to create, assemble, and test.
    2. Disadvantages. May be difficult to find and might require developer (as opposed to Administrator) support to modify. Also, can be very tricky using multi-linguistic sites. (Hint: USE LABELS!!)
  2. Plain Text Body. Even when you’re sending out an HTML email, a plain text alternative can be desirable. Multi-part MIME (Multipurpose Internet Mail Extensions) bundles together a simplified plain-text version of your email along with the HTML version of your email. You cannot use plainTextBody and a template.
  3. Both an HTML Body and a plain text body. Use this to send out and HTML email with a bundled plaint-text version. You cannot combine this option with a template.
  4. Email Templates (Classic or Lightning Email Template). Use Email Templates (Lightning EmailTemplate strongly preferred) to save time and standardize email sent by you or others in your organization. Use merge fields or enhanced letterhead if you need them. This has been an evolving function within SalesForce, so if you are unfamiliar with email template options, you may want to review this. Details on how to use EmailTemplates in multilingual environments can be found here.
    1. Advantages. Consolidates standard communications within the SalesForce email structure (both Classic and Lightning). If you’re using Lightning Email Templates, you have the full range of public, private, and specified sharing capabilities for who can use what and it helps enforce communication standards by making the development of templates and communication more of a communication and policy role rather than a developer or administrator role.
    2. Disadvantages. Users need to understand the concept of templates and sometimes the differentiation between Classic, Lightning, and (sometimes) VisualForce templates.
  5. Multi-Lingual Email Templates (only tested with Lightning EmailTemplates).

Body – HTML Body

Rich Text HTML email bodies 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.

To send a rich text (HTML) body, create a resource of type “Text Template” and specify that resource when sending the email with the sendHTMLEmail action.

This image has an empty alt attribute; its file name is TextTemplateResource.png
Text Template Resource named “HTMLTextTemplate”
This image has an empty alt attribute; its file name is sendHTMLEmailRichTextBody.png
HTMLbody Parameter in sendHTMLEmail Action

Body – HTML Body Reference

NAMETYPE
HTMLBodyString(or Text Template from Flow)

Body – Plain Text Body

Even when you’re sending out an HTML email, a plain text alternative can be desirable. Multi-part MIME (Multipurpose Internet Mail Extensions) bundles together a simplified plain-text version of your email along with the HTML version of your email. You cannot use plainTextBody and a template.

To send a plain body text:

1. [Optional] Create a text resource, either variable or a formula if you wish to insert line breaks:

2. You can just enter text, or specify the resource in the action input values.

Body – Plain Text Body Reference

NAMETYPE
plainTextBody String

Body – Both an HTML Body and a plain text body

[RFU] Previous versions of SalesForce allowed for templates which automatically attached text-only versions in the event a recipient did not desire and/or have the capability to use HTML-based email. As of this writing, it appears the Lightning Email always sends the HTMLBody, but does not attach the plainTextBody.

Name Or LabelType
HTMLbodyString
plainTextBodyString

Signature

You can decide whether or not to include the User email signature if the context user has one configured. The default is true, meaning if the user has a signature it is included in the email unless you specify false. Note: You must enable this parameter AND specify it as $global.false if you want to shut it off.

This image has an empty alt attribute; its file name is image-21.png

Signature – Reference

Name Or LabelType
UseSalesforceSignature Boolean

Attachments

You can attach files to your emails. This Action uses the ContentDocumentAttachments  associated with the newer Files/Content mechanism using a more flexible and modern mechanism that allows for multiple versions of a document This input value is expected to be a collection/list of Content Document Links (CDLs). To learn how to attach documents using CDLs, see more here.

This image has an empty alt attribute; its file name is image-13.png

Attachments – Reference

Name Or LabelType
contentDocumentAttachmentsList<ContentDocumentLink>(or Collection of ContentDocumentLink in Flow)

Templates

For a nice introduction on how to use email templates, letterheads and even graphics, you may wish to start here: Configure an Email Letterhead and Template.

Considerations

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.

Use an Email Template

Use Email Templates (Lightning EmailTemplate strongly preferred) to save time and standardize email sent by you or others in your organization. Use merge fields or enhanced letterhead if you need them. This has been an evolving function within SalesForce, so if you are unfamiliar with email template options, you may want to review this. Details on how to use EmailTemplates in multilingual environments can be found here.

When you use email templates, consider 3 core integration points – the first for the template itself, and the others for identifying the recipient and merging information into the email:

  1. The Template. The template contains the format of the email (including Letterhead) and syntax for merging fields into that communication. A merge field is a placeholder in an email template or letterhead. When you send the email, the placeholder is replaced with the Salesforce data from the record or records of the people you are emailing. Fields that can be merged include those from the TargetObject, another sObject record, and global variables.
  2. The Target Object Record. This is record for the recipient of the email. When used, it is the ID of the contact, lead, or user to which the email will be sent. Depending on the type of template you are using, other fields from the TargetObject can also be merged into the template to create the email (e.g., Name). The ID you specify sets the context and ensures that merge fields in the template contain the correct data. For further details, see setTargetObjectId(targetObjectId)
  3. The Related Record. If you specify a contact for the  TargetObject  field, you can specify an optional whatId(RecordId) to ensure merge fields in the template contain the correct data. For further details, see setWhatId(whatId)

Email Templates(Standard)

For a standard template, the Template ID and the Template Target Record Id (Recipient) are required. Optionally a related record can be specified using the Template/Activity RecordId(whatId/recordId) Input Value.

Email Templates(Standard) – Reference

Name Or LabelTypeDescription
Related Record ID(whatId/recordId)  If you specify a contact for the targetObjectId field, you can specify an optional whatId as well. This helps to further ensure that merge fields in the template contain the correct data. This is used for merge fields and for associating activities and attachments.
Template Target Record IdStringIf you are passing in a template Id, you need to also pass in the Id of context record. It can be a Contact, Lead, or User. It will determine which data gets merged into the template’
templateIDString


Multilingual Email Templates (only tested with Lightning EmailTemplates)

SendHTMLEmail provides multi-lingual support within the same flow by allowing the language to be specified, then selecting the appropriate template for that language. For this functionality, each language localization has its own template with all localizations sharing a common EmailTemplate.Name. To differentiate the localizations, add a tag to the EmailTemplate.Description field in the format: ‘Language=”en_US”‘ (or whatever corresponding to your organization localizations).

Each localization template is created (and used) as an individual email template. For detail reference on how to add localization to an email template set, please refer to Send HTML Email with Multi-Language Support for Lightning Email Templates.

Multilingual Email Templates – Reference

Name Or LabelTypeDescription
Related Record ID(whatId/recordId) String If you specify a contact for the targetObjectId field, you can specify an optional whatId as well. This helps to further ensure that merge fields in the template contain the correct data. This is used for merge fields and for associating activities and attachments.
Template LanguageStringUsed in conjunction with Template Name, Finds templates with the name matching Template Name for ‘Language=”xxx_YY”‘ in the Description.  Template Selection criteria order first found Name with: 1)If empty, Org LanguageLocaleKey 2)Language found in Description 3)First without ‘Language=”‘
Template NameStringUsed in conjunction with Template Language. Finds templates with the name matching Template Name for \’Language=”xxx_YY”\’ in the Description.
Template Target Record IdStringIf you are passing in a template Id, you need to also pass in the Id of context record. It can be a Contact, Lead, or User. It will determine which data gets merged into the template’

Activity Save – Linking the Email To a Record (Logging Sends)

You can save an email was sent as an activity for a record. This is based on setSaveAsActivity(saveAsActivity) and is Optional. The default value is true. If this is set, you must also specify a valid Related Record ID(recordID) for where the email activity should be saved. This argument only applies if the recipient list is based on targetObjectId or targetObjectIds. If HTML email tracking is enabled for the organization, you will be able to track open rates.

This image has an empty alt attribute; its file name is image-20.png

Activity Save – Linking the Email To a Record (Logging Sends) – Reference

Name Or LabelTypeDescription
Related Record ID(whatId/recordId) String If you specify a contact for the targetObjectId field, you can specify an optional whatId as well. This helps to further ensure that merge fields in the template contain the correct data. This is used for merge fields and for associating activities and attachments.
saveAsActivityBoolean

Examples

The sendHTMLEmail package ships with two screen flows that can be used to test and demonstrate the action, ‘Send HTML Email Testflow’ and ‘sendHTMLEmail Test – Create Test Templates if Needed’. You do not have to activate these flows to use them. Open ‘Send HTML Email Testflow’ then select “Debug” (or “Run”).

This image has an empty alt attribute; its file name is image-27.png

Some of these examples may require prior setup of records. Where necessary, this is described in each of the selected examples. Examples/Tests include:

  1. Simple Email Text – with To, Sender, Reply-To, Subject, Body (All text)
  2. Simple Email with Address Collections – Using Address Collections to Send to Multiple Recipients
  3. Email with Attachments – Simple Email (1) With Attachments
  4. Email Using Template – An email using a Lightning EmailTemplate
  5. Multi-Lingual Using Email Templates – An email using a Lightning EmailTemplate selected by language

Choose the example you would like to see and the instructions are in each of the examples. You will also find in these examples the use of Text Templates for formatted Rich Text messages (Example 1), using Plain Text (Example 2), and logging the email as an activity on the related object (Example 5).

Select Test Flow and Start an example

To see how the Send HTML Email Action is configured for each of these examples, click on the appropriate Action (they are labeled) and look at the Input Variables. You may also want to look at some of the logic in the setup to those examples for ideas in creating your own flows.

This image has an empty alt attribute; its file name is image-22.png

Example 1 – Simple Email Text – with To, Sender, Reply-To, Subject, Body (All text)

This sends out a rich text email predefined as a text template () l to the addressee in [Recipient Email Address] from [ReplyTo Email Address] with the name [Sender Name] using [Subject] and [Body]

All of the above can be created by assigning variables. To create a body with line breaks, use a formula variable (see example variable testPlainTextLineFeeds)

Note: To get the full effect of rich text, edit the formula plainTextBody instead of modifying the field on this screen.

Example 2 – Simple Email with Address Collections

This sends out a simple plaintext email from [ReplyTo Email Address] with the name [Sender Name] using [Subject] and [Body]

All of the above can be created by assigning variables. To create a body with line breaks, use a formula variable (see example variable testPlainTextLineFeeds)

The addressees can be built from multiple collections. This example builds a collection of strings from the two email strings and/or from collections you can set up external to the example flow by creating contacts with names containing the text entered in [Contact Contains Match].

By default, this example builds a collection of strings from the two recipient email addresses and will send all collections to To, CC, and BCC (so 6 emails will be sent – minimum)

Example: Create two contacts with valid email addresses and names containing “testContact”, then specify “testContact” in [Contact Contains Match]

Note: To get the full effect of rich text, edit the formula plainTextBody instead of modifying the field on this screen.

Example 3 – Simple Email with Address Collections

For this example, you will need to create or use a record to which attachments can be made (e.g., a Contact). Create the record and then use the recordId of that record to attach files.

This sends out a simple plaintext email with attachments from uploaded files to the addressee in [Recipient Email Address] from [ReplyTo Email Address] with the name [Sender Name] using [Subject] and [Body]

All of the above can be created by assigning variables. To create a body with line breaks, use a formula variable (see example variable testPlainTextLineFeeds)

Note: This example as distributed uses the formula variable “testPlainTextLineFeeds” to create a plain text body without signature

Example 4 – Email Using Template

This sends out an email using a specified EmailTemplate with the addressee specified through the TargetObjectId and optionally (dependent on your Template) merge fields with an associated object record using that record’s Id.

For this example, you will need to create or use a template. Templates also require that you have a recipient record (targetObjectId) (e.g., Contact, User, . . .) which must also pre-exist. You will be required enter the ID for that record as the (targetObjectId). Additionally if you intend to test merge fields (RelatedTo) with your template, you must also pre-create the related object record and have available the Id for that record as an ID for the Record Object Id (RecordId).

Example 5 – Multi-Lingual Using Email Templates

SendHTMLEmail provides multi-lingual support within the same flow by allowing the language to be specified, then selecting the appropriate template for that language. For this functionality, each language localization has its own template with all localizations sharing a common EmailTemplate.Name. To differentiate the localizations, add a tag to the EmailTemplate.Description field in the format: ‘Language=”en_US”‘ (or whatever corresponding to your organization localizations)

This example uses the template set sendHTMLTest with english (en_US) and spanish (es_MX) versions. If the templates do not exist, this example will automatically create them for you (sendHTMLEmailTest).

You will also need to:

  1. Create a Contact (for Target Object) and have its Id available.
  2. Create an Account (for Related Record) and have its Id available.

You can, of course, vary the templates and object records to reflect your organization’s needs.

This sends out an email using a specified EmailTemplate with the addressee specified through the TargetObjectId and optionally (dependent on your Template) merge fields with an associated object record using that record’s Id.

For this example, you will need to create or use one or more templates. Templates also require that you have a recipient record (targetObjectId) (e.g., Contact, User, . . .) which must also pre-exist. You will be required enter the ID for that record as the (targetObjectId). Additionally if you intend to test merge fields (RelatedTo) with your template, you must also pre-create the related object record and have available the Id for that record as an ID for the Record Object Id (RecordId).

Reference

Name Or LabelTypeDescription
contentDocumentAttachmentsList<ContentDocumentLink>(or Collection of ContentDocumentLink in Flow)
HTMLbodyString
orgWideEmailAddressIdString
plainTextBodyString
Related Record ID(whatId/recordId) String If you specify a contact for the targetObjectId field, you can specify an optional whatId as well. This helps to further ensure that merge fields in the template contain the correct data. This is used for merge fields and for associating activities and attachments.
replyEmailAddressString
saveAsActivityBoolean
SendBCCtheEmailAddressesFromThisCollectionOfContactsList<Contact>(or Collection of Contact in Flow)
SendBCCtheEmailAddressesFromThisCollectionOfLeadsList<Lead>(or Collection of Lead in Flow)
SendBCCtheEmailAddressesFromThisCollectionOfUsersList<User>(or Collection of User in Flow)
SendBCCthisOneEmailAddressString
SendBCCthisStringCollectionOfEmailAddressesList<String>(or Collection of String in Flow)
SendCCtheEmailAddressesFromThisCollectionOfContactsList<Contact>(or Collection of Contact in Flow)
SendCCtheEmailAddressesFromThisCollectionOfLeadsList<Lead>(or Collection of Lead in Flow)
SendCCtheEmailAddressesFromThisCollectionOfUsersList<User>(or Collection of User in Flow)
SendCCthisOneEmailAddressString
SendCCthisStringCollectionOfEmailAddressesList<String>(or Collection of String in Flow)
senderDisplayNameString
SendTOtheEmailAddressesFromThisCollectionOfContactsList<Contact>(or Collection of Contact in Flow)
SendTOtheEmailAddressesFromThisCollectionOfLeadsList<Lead>(or Collection of Lead in Flow)
SendTOtheEmailAddressesFromThisCollectionOfUsersList<User>(or Collection of User in Flow)
SendTOthisOneEmailAddressString
SendTOthisStringCollectionOfEmailAddressesList<String>(or Collection of String in Flow)
subjectString
Template LanguageStringUsed in conjunction with Template Name, Finds templates with the name matching Template Name for ‘Language=”xxx_YY”‘ in the Description.  Template Selection criteria order first found Name with: 1)If empty, Org LanguageLocaleKey 2)Language found in Description 3)First without ‘Language=”‘
Template NameStringUsed in conjunction with Template Language. Finds templates with the name matching Template Name for \’Language=”xxx_YY”\’ in the Description.
Template Target Record IdStringIf you are passing in a template Id, you need to also pass in the Id of context record. It can be a Contact, Lead, or User. It will determine which data gets merged into the template’
templateIDString
UseSalesforceSignatureBoolean

Installation

  • 1.33 Unmanaged sendHTMLEmail (with Flow Examples/Tests) – Added documentation, validations, examples)
  • 1.33 Unmanaged sendHTMLEmail(No Tests) – No Flow tests or examples (Added documentation, validations)
  • 1.32 Unmanaged – Adds Bulkification

Old versions

1.31 UnmanagedParagraph

1.2 Unmanaged (attachments are supported using Attachments instead of Content Document Links)

1.0 Unmanaged

1.0 – Managed (requires Winter ’20)

131
Leave a Reply

avatar
39 Comment threads
92 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
37 Comment authors
Jack PondFlorianJack D. PondStéphane Houlethompsst Recent comment authors
  Subscribe  
Notify of
Megan Moody
Guest
Megan Moody

I was able to get this work – awesome! – but the sender comes through as unverified. I’m populating the replyEmailAddress variable with one of our org-wide email addresses. Is it because I’m sending from a sandbox? Will the behavior be different in production? Also, is there any trick to adding images to the text template being used for the HTML body? I added one, but it doesn’t go with the email. Thanks for any tips you can provide!

George
Guest
George

Amazing to have Lightning Emails available in a flow – thanks. Am I right in saying that this currently doesn’t support custom object merge fields in the template email – can only be merge fields on the contact, user or lead object?

Richard
Member
Richard

Hello Alex,

thanks a lot for your hard work, I am looking for that kind of solution for a long time. Unfortunately the link for the updated version (1.1 unmanaged) is not working. I only see “v0.1 Beta” in the version details and the testing flow is not opening at all (loading loop, so I can’t open it) after package installation.

Can you provide a new link to the actual update?

Thanks a lot!

Nkosi
Guest
Nkosi

Hi, thanks a lot for your hard work . I am just having issues with a null pointer exception if I dont include an attachment and no email is being sent when attachments are included, no error but no email sent

Moulin
Guest
Moulin

Well, I have solved this issue. When you get the attachment in your flow, you have to request all the fields (Id, Name, Contentype and Body). Once you have requested all these fields, it works fine.

dani
Member
dani

Hi Alex,
thank you for this development, is there any chance when send the email , save it under the activity history ?

Derek Hawley
Guest
Derek Hawley

I really appreciate all the work you do with Flows and the time you dedicate. This website has been a huge asset for me. I wanted to ask if there is a way for this to work with an email relay? When using the simple email action, emails are sent from my email relay. When sending emails using SendHTMLEmail Action they are sent via the Salesforce domain.

Thanks for the help.

Tamar Erlich
Guest
Tamar Erlich

Hi Alex, can this functionality be extended to use an email field or variable to specify the sender email (e.g. I want the email to come from the contact owner’s manager or the SE on the contact’s account team)
Thank you for all the amazing work you do for the Flowhana

Gidi Abramovich
Editor

Alex Hi,
Your Email solution is great!!!
We are finally able to receive rich text emails without HTML tags 🙂
Is it possible to add multiple recipients’ emails with comma-separated?

It will be great if we could define a Public Group as a recipient, so all of its Group Members will receive the email.

Thanks a lot for the hard work you are doing!

Gidi

Richard
Guest
Richard

Toggle signature on / off doesnt seem to do anything. Current user’s salesforce signature gets added into the email no matter what. Can we fix this 🙂

Anonymous
Guest
Anonymous

Hi Alex,

Merge field option is just for contact lead and users in classic and lightning templates both. Is this correct ? will not work for any other objects.

Also I installed the package in sandbox but send html email action does not appear.

Josh Dayment
Guest
Josh Dayment

Is the inline image still a bug I have tried copy and pasting as well as using the image button via the text template editor but images are still coming through broken in the email.

Anonymous
Guest
Anonymous

Yes, support for images is not yet implemented there.

Eli Pogorelov
Guest

HI, I installed the package, but receiving an error when entering the Send HTML email Test flow : Failng descriptor {markup://builder_platform_interactions:canvas}

shahar
Guest

Hi, could anyone explain how to install this package? I’m quite new to this field

Megan Moody
Guest
Megan Moody

I just installed and tested 1.31. The email sends great, however, it’s not adding a copy of the actual email to the case feed. Is there a way to do this? I am pretty sure a previous version of this did this. I tried setting saveAsActivity to TRUE, but that just logs that an email was sent and doesn’t display the actual email sent. I am trying to send via a template.

Megan Moody
Guest
Megan Moody

I also tried sending via an HTML body from the action itself (vs. a template) and that didn’t save the actual email to the feed either.

trackback

[…] a Flow that uses the Send Rich Email action. Use the “Autolaunched” Flow Type. Configure the flow with input variables to capture […]

Wendy Tanner
Guest
Wendy Tanner

Is there an option to review the email before sending it? This looks like a solution, but the team wants to choose the template then review before sending.

Jem
Guest
Jem

I tested this on Sandbox and it works well but when I tried in prod it only works if its triggered by users or PB but not with scheduled flow. :'(

Josh Dayment
Guest
Josh Dayment

I have a flow where I do something similar where I store the email body in a variable and display that variable on a screen using display text. I also have another version where we actually store the email in a custom object (very specific use case) then I use the recorddetail component to actually update the email body.

Yanir
Guest
Yanir

This is a huge Help!!

Is there a way to send HyperLink to a record in a text Template resource? I haven’t found a way to send a link to a record that is nice and tidy… I was only able to send a full https://…./{!CaseID} as link.
It could be beautiful if I could be able to send only the Case number as the link to the record.
Someone has tried that and figured it out?

Yanir
Guest
Yanir

Has someone found a way to send HyperLink to a record in a text Template resource?

Josh Dayment
Guest
Josh Dayment

I use the hyperlink functionality right in the text template and use a separate variable that is unique to each record I store a url on {!Get_Attendee_Record.Annotated_Post_Event_Survey_URL__c} in another use case I type out the url and if I need to pass the record id I use a variable there as well i.e. https://my.salesforce.com/{!recordId}/view

Yanir
Guest
Yanir

Hi Josh, Thank you for your answer.
I currently use the second option – display the url but I would like to only expose a short text as the link to the record. Would you be able to post all the formule with the hyperlink that you use – I couldn’t quite figure it out from your comment.

I will much appreciate this 🙂

Thank you.

Yanir.

Josh Dayment
Guest
Josh Dayment

shoot me an email to josh.dayment@recruitmilitary.com and I will send you a few screenshots

Kou Xiong
Guest
Kou Xiong

Is there a reason why the ConverAttachment action is not included in the 1.31 version?

Jack D. Pond
Guest
Jack D. Pond

Using the SendHTMLEmail, you can send emails in a selected language using the localized version of and email template. I’ve forked a project for our own use but If there’s interest, I’d be glad to contribute the work.

For details, see https://github.com/jdpond/LightningFlowComponents/blob/master/flow_action_components/SendHTMLEmail/README.md

and https://github.com/jdpond/LightningFlowComponents/projects

Bill Fox
Guest

We do not use CRM and have built a platform on force.com. We do not have Accounts, Contacts or Leads. Will this work for custom objects?

Alex Edelstein
Guest
Alex Edelstein

You’ll need a flow action that extracts email addresses from your custom objects And turns them into a collection of strings that this action can except as input.That’s easy to do with Invocable Actions and Apex

Peter J. Rozek
Guest
Peter J. Rozek

We are attempting to use this with a Visualforce template. The process starts at Process Builder on a Opportunity. Opportunity details are merged into the template. Is there a way to tell the visualforce template the ID of the opportunity to use in it’s merge fields?

Peter J. Rozek
Guest
Peter J. Rozek

We’re feeding value in, but we’re getting this error, despite having set the value to Global Constant.False

errors (SendEmail failed. First exception on row 0; first error: INVALID_SAVE_AS_ACTIVITY_FLAG, saveAsActivity must be false when sending mail to users.: [saveAsActivity, true])
isSuccess (false)

Anonymous
Guest
Anonymous

Has there been any change to the support of including images in the email body?

Pedro Carmo
Guest
Pedro Carmo

Hey Alex, I’ve managed to get the action working fine, except for 2 minor hiccups: 1. When trying to use the SendTOthisStringCollectionOfEmailAddresses – I’mflow trying to push a longtext field (where I’m already capturing a list of email addresses separated by comma: email1@email.com,email2@email.com,etc…) into that option, but it doesnt allow me to choose any fields on the Record (Single) Variables – it only presents options for lookup fields of the record, not any other field type… 2. I’ve configured the PB/Flow combo in a way that I trigger the flow action in 2 or more (child) Cases simultaneously, via a… Read more »

trackback

[…] input parameters requires strings in one of two forms. Send Rich Email, for example, can take a list of string email addresses but can’t (currently) take a […]

trackback

[…] Check it out […]

Peter J. Rozek
Guest
Peter J. Rozek

Hi Alex,

I had replied to my own post from Feb 6th with some additional information; not sure if you saw it. Any thoughts about the error and how to identify the correct record to feed the email template?

Many Thanks,

Peter

trackback

[…] This is extended functionality of Send Rich Email. […]

Ryan Schierholz
Guest
Ryan Schierholz

Thank you for your work on this, Alex. I am a user of Jeremiah’s ‘Legacy’ version, so when I saw someone had built on that, I was excited to check it out. However, I am shocked that I cannot find the ability to link the email sent (Save As Activity) to the contact(s) receiving it. In Jeremiah’s version, there is a Target Object Id which allows me to save to the activity log for that Contact. Did I overlook something (I’ve looked many times) or did that get removed from your adaptation?

Jack Pond
Editor

Ryan, I just ran a test and it was successful. There are 3 parameters you should consider
saveAsActivity = true
Associated RecordId(WhatId/recordId for template and activity) = the record on which the activity will be posted
Template Target Record Id = the record to which the email will be sent.

Note: In classical templates to determine which merges/activities,
Recipient == Target Record Id
relatedTo=WhatId/recordId (this is where the activity will be posted, not on the Target RecordId)

Alex Edelstein
Guest
Alex Edelstein

Jack, this is a great example of where the functionality is powerful but the documentation needs to surface it more. let’s add a specific section to the main documentation here at https://unofficialsf.com/send-rich-email-with-the-new-sendhtmlemail-action/ called something like “Linking the Email To a Record (Logging Sends)” that makes this easier to find

Jack Pond
Editor

Agreed – and I’m going to try and look at it in a more holistic view
1) The functionality is very complex and not well documented anywhere – even within the SF Documentation of the Messaging class. I got very confused between TargetObjectId and WhatId, and the only way I figured it out was trial and error
2) This is a class area for CPE, but even then, it needs to be rethought re: complexity and presentation in a more logical delineation.
3) Is there someone on the team that can help here? I always sucked at clear, concise documentation

Alex Edelstein
Admin

If you want to write a first draft, I’ll do an edit pass on it. Just write it out as if you were trying to explain it, and add images where convenient.

Ryan Schierholz
Guest
Ryan Schierholz

Thanks. FYI, when I try to ‘like’ a comment here, i’m presented a login screen. I use Google (which worked on the original comment), but then it loops me back to trying to login with WordPress. Never works to ‘like’ as logged in with Google.

Nino Y.
Guest
Nino Y.

What is the expected input for the email collection fields? It keeps saying “invalid input” for whatever I try.

Jack D. Pond
Guest
Jack D. Pond

Nino, They expect a collection of objects. If you are invoking through Apex, it would be a list of objects for example.
List<Contact> thisParam = new List<Contact>{ new Contact(), new Contact() }
If you are invoking through a Flow, it would be a collection variable. Example when you create the New Resource:
Resource Type == Variable
API Name == [Your API Name]
Data Type == Record
Select checkbox Allow Multiple Values (Collection)
Object = Contact

Anonymous
Guest
Anonymous

Hi Jack, I’m trying to use the Flow. Would they have to be a Contact object? could I do an area of string?

Nino Y.
Guest
Nino Y.

I am trying to use the Flow. Would the variable have to be a contact? could it be just an array of strings?

Ryan Schierholz
Guest
Ryan Schierholz

Hey guys, I am doing another testing of this. (Thanks for the feedback on the settings the other day.) This time, I am trying to pass in an Email Template ID, so when it’s updated in the future, I don’t have to re-publish a flow. The email goes to a User an dis associated with a custom object Closing. I have linked the Closing__c object on the Email Template in the Related Entity Type field. I have set the Associated Record Id / WhatId to the recordId of the Closing__c object for the flow, and the Template Target Record Id… Read more »

Jack Pond
Editor

Ryan, sorry for the delayed response. I get this message when I am trying to use Enhanced Letterhead with community initiated flows. SF has confirmed there are issues in this framework. https://success.salesforce.com/answers?id=9063A000000q0zk. If there are other fields/issues, I can add this to the same support request which is currently with the SF Development Team. The latest I heard was as follows: I would say that at this point, the issue has been narrowed down to the Guest User access logic, which has been under a lot of adjustments recently. A logged-in user on a Community would likely be able to… Read more »

Anonymous
Guest
Anonymous

Thanks for the reply, Jack. So, this is NOT community/guest access and I did NOT specify any letterhead on the template; therefore, it seems that would not be applicable to me … ?

Jack Pond
Editor

I should have said that better – the entire EmailTemplate environment is under review because of the issue about REQUIRED_FIELD_MISSING – which varies between different Objects, Standard and Custom. The best advice I can give you is set up a log and determine WHICH field is not being viewed – it will probably come down to either a sharing problem or you are using a standard object that may somehow be restricted for the license type of the user context you are in when executing the flow.

Ryan
Guest
Ryan

Ryan, did you ever figure this out? I’m running into the same issue

Ryan Schierholz
Guest
Ryan Schierholz

I have not had more time to spend on it.

Jack Pond
Editor

Ryan, were you able to determine WHICH field is the REQUIRED_FIELD_MISSING?

Clay Davis
Guest
Clay Davis

So far, this is working as intended EXCEPT for attachments. I am using the newest version and passing a collection variable of ContentDocumentLinks into the action as shown. The Email sends, but there are no files attached. I have verified that the collection variable contains at least one ContentDocumentLink Id. Any guidance?

Alex Edelstein
Admin

Hmm. I just tried it out and verified that it works on my org. Double check the new content at https://unofficialsf.com/using-files-and-attachments-in-flow/ . However it sounds like you’re doing the right thing. Upgrade to version 1.32 if you’re not already on it. I think someone broke attachments a ways back and then it was fixed. Make sure the file you’re testing with is innocuous (small, simple).

Clay Davis
Guest
Clay Davis

Alex, thanks for the reply. I figured it out. I hadn’t included the ContentDocumentId in the sobject variable feeding the collection. Once I corrected that, everything worked as intended.

John Seale
Guest

Hey – this is a perfect plugin, but I’m having a funny issue – when I build the flow, it works just great in my testing. But as soon as I turn it into an autolaunched flow, when the time comes around I get the error “Error element Send_The_Email (FlowActionCall). Profile does not have access to sendhtmlemail”

This is probably less an issue with your code and more an issue with my implementation, but what am I missing? Why does it work when I run it manually from the Flow Builder, and not when Salesforce tries to auto-launch it at midnight?

Jack Pond
Editor

Hey John, I will be the first to admit that I’m NOT a skilled administrator, but given your problem, it sounds like your User Profile may have Enabled Class Access to sendHTMLEmail, but whatever user context the midnight autolaunching is launching in does not. You can check with Setup–>Apex Classes–>SendHTMLEmail–>Security or make sure you installed for all users.
Add Profile to Access

John Seale
Guest

Sadly, I just checked that and it is enabled for all profiles….

Alex Edelstein
Admin

Check out the Considerations at https://unofficialsf.com/the-salesforce-automation-and-decisioning-wiki/scheduled-flows/ . It looks like there might not be a way to mix invocable actions and scheduled Flows right now, if you’ve enabled the CRUC for Apex Security, because we don’t have a way to enable the Automated Process User to have access to specific Apex classes. I’m looking into how this will be addressed.

John Seale
Guest

Sad! I’ve just deactivated “Require User Access to Apex Classes Invoked by Flow”. I’ll let it go overnight and we’ll see it if fails or succeeds overnight. There’s 349 days until this update is automatically activated, so at least we can push that long! Maybe Salesforce will provide a workaround in the meantime, or they’ll build HTML email into flows themselves.

John Seale
Guest

I’ve been fiddling with this, and it’s still giving me fits. After deactivating the critical update, the whole process became invisible. No more error, but no email either. Now scheduled autolaunched flows aren’t sending any emails at all. I even tried creating a dummy flow to be autolaunched at a specific time, and literally all it does it start, create a silly record (so I can tell it did actually run), and send an email using both the built-in SF sendemail action and your sendhtmlemail action. The flow runs, creates the silly record, and then that’s it. Silent failure. Any… Read more »

Roland P.
Guest
Roland P.

Hi – this has been great to integrate so far. I am building a flow to forward lead information to our sales partners via Email. My flow takes the recordID (goes into Template Target Record Id) from the lead it has been started from. Then it takes the current user and finds a classic email template by UserID. All works well except the message gets sent out to the Lead Email address. I have nothing in Send HTML Email that would trigger such a behaviour. What am I missing here? I only want the message to go out to the… Read more »

Jack Pond
Editor

Template Target Record Id[templateTargetObjectId] == Recipient and Associated RecordId(WhatId/recordId for template and activity)[recordId] ==
Lead

Anonymous
Guest
Anonymous

I have “Template Target Record Id” == {!recordId} == Lead
Associated RecordId is not included. Does this need to be set? The flow runs as expected except it sends a copy to the lead address even though it is not mentioned in flow variables or anything alike. It behaves just as if I would have drawn up the email template in the regular email function on leads.

Jack Pond
Editor

see above. you need to assign both Recipient Id and Lead Id to their respective params

thompsst
Guest

Is there any way to get an installable package that excludes the TestFlow? There’s a step in the TestFlow that Gets Contacts. Trying to install this package fails because we have an encrypted field tied to Contacts. We do not have a use case to email Contacts, so this should not be a road block.
“Flow filters can’t reference encrypted fields” is the error that displays.

Jack Pond
Editor

@thompsst, Currently in alpha development is a new version that does not automatically create the Contacts for tests and a version that does not have tests included at all. If you’d like to try them out and give some feedback whether this helps you, I’d appreciate it.

1.33 Unmanaged sendHTMLEmail (with Flow Examples/Tests) – Added documentation, validations, examples)
1.33 Unmanaged sendHTMLEmail(No Tests) – No Flow tests or examples (Added documentation, validations)

Draft DocumentationDraft Documentation for 1.33

Stéphane Houle
Guest
Stéphane Houle

I am on 1.3 (keep getting error messages when I try to upgrade to 1.32). Whenever I try to send an email with an attachment (using Content Document Link), my flow debug screen gets stuck infinitely on the screen before the email gets sent. The flow works fine without attachments.

Any idea?

Jack Pond
Editor

Stéphane, what type of related object are you using when specifying recordId?

Stéphane Houle
Guest
Stéphane Houle

CPQ Quotes (SBQQ__Quote__c_).

Stéphane Houle
Guest
Stéphane Houle

I’m trying to get Quote PDFs on the Primary Quote of my Opportunity (which is my starting record).

Jack Pond
Editor

So your Template Target Record Id(templateTargetObjectId) is Opportunity and your Related Record Id (recordId) is SBQQ__Quote__c?

Stéphane Houle
Guest
Stéphane Houle

I don’t use any of those parameters, I’m using a text template that’s in the flow itself since I’m passing information from my flow screen and multiple related objects.

Just realized there was also a video, so I’ll watch it and hopefully I’m just missing some easy stuff somewhere :).

Jack Pond
Editor

Look especially at: Template Target Record Id(templateTargetObjectId) is set to Opportunity Id and your Related Record Id (recordId) is set to the SBQQ__Quote__c Id

Florian
Guest
Florian

Hi there, I’ve received the following error message while trying to install the latest version (1.32): Your request to install package “SendHTMLEmail ver 0.1” was unsuccessful. None of the data or setup information in your salesforce.com organization was affected. If your install continues to fail, contact Salesforce CRM Support through your normal channels and provide the following information. Organization: xxx User: xxx Package: SendHTMLEmail (04tB0000000Awk2) Problem: 1. Apex compile failure Apex class Test_ApplicationDetailsLightningCtrl: line 59, column 69: Method does not exist or incorrect signature: void getAllOpportunityFiles() from the type ApplicationDetailsLightningController 2. Apex compile failure Apex class Test_ApplicationDetailsLightningCtrl: line 75, column… Read more »

Jack D. Pond
Guest
Jack D. Pond

Florian, There is a beta version awaiting pull – if you’d like to be a pilot tester, give one of these a try (They both should not encounter the issue):
INSTALLATION
1.33 Unmanaged sendHTMLEmail (with Flow Examples/Tests) – Added documentation, validations, examples)
1.33 Unmanaged sendHTMLEmail(No Tests) – No Flow tests or examples (Added documentation, validations)

Florian
Guest
Florian

Hey Jack, thanks for your quick reply! I receive the same errors while trying to install one of the option you’ve mentioned. But thats fine for me as 1.31 seems to work for me at the moment. However I’ll attache the error message: Package: sendHTMLEmail(No Tests) (04t3h0000019dUk) 1. Apex compile failure Apex class Test_ApplicationDetailsLightningCtrl: line 59, column 69: Method does not exist or incorrect signature: void getAllOpportunityFiles() from the type ApplicationDetailsLightningController 2. Apex compile failure Apex class Test_ApplicationDetailsLightningCtrl: line 75, column 17: Variable does not exist: documentSelection 3. Apex compile failure Apex class Test_ApplicationDetailsLightningCtrl: line 79, column 62: Method does… Read more »

Jack Pond
Editor

Florian, Let’s try and contact directly, then post what we found here instead of cluttering this thread – you can find my information on github, https://github.com/jdpond

trackback

[…] Send Rich Email (Send HTML Email Action) Ver 1.33 has been released. It is a minor bug fix and document update release including: […]