Send email-alerts and log the email.

Use process build, flow or apex to send an email

See the sent email in the activity feed

#1 Install

  • Upvote the idea for Salesforce to make this standard.
  • Install the package – this only works on Enterprise edition and up as it requires apex code. Or view in GitHub.
  • Open a process builder (or flow)
  • On the actions select the “Apex Class” option

#2 Select the recipients

  • Related To ID – the ID of the record you want to relate this to (eg. account or opportunity). Not a contact, lead or user
  • Contact/Lead/User ID – Required if you use an email template
  • ToAddresses – enter a comma-separated list of email address. Eg.,
  • bccAddresses – comma-separated list of email addresses to go into the BCC field
  • ccAddresses – comma-separated list of email addresses to go into the CC field

#3 Enter the email content

  • Email Template Id – the id of the email template. eg. 00X600000012maf
  • Or instead, use “Email Template Name” with the unique name (API name) of the email template. eg. “Email_template_name”

Or write your own content

  • You cannot these three items with an email template due to a limitation in Salesforce Apex:
    • Subject – specify the subject
    • PlainTextBody – enter a plain text body
    • HtmlBody – or an HTML body

#4 Optional Extras

  • OrgWideEmailAddress – Specify a specific from address. This must be an org wide email address.
  • Save As Activity – You decide if you want to log the email as an activity or not. Defaults to True
  • emailOptOutPolicy – this helps define what you do if a user has opted out of receiving emails:
  • Attachment – ContentDocument — This is the ContentDocumentId of the document you want to attach. It will take the latest ContentVerion.
    • Otherwise, you can use ‘Attachment – ContentVersion’ to specify a specific ContentVersionId


  • Apex email sends have a limit of 5000 per day across your org. Note that all recipients in the to, cc and bcc fields count against this limit  An example being an email with 2 addresses in the “to” field and 1 address in the “cc” field would count as 3 calls against the limit.


Share this post

16 thoughts on “Send email-alerts and log the email.

  1. Hey guys! Thanks for the app! Looks pretty straight forward, I’ve set it up in one of the process builders, the email gets sent, but so far i was not able to attach the activity to neither Lead, Account or Contact, regardless whether i set the relatedTo dynamically or hardcode the value. Any thoughts what might be causing this?

    • Hi Konstantin,
      I’m glad the tool is going to help. Remember that any records for people (Contact/Lead/User) should not go in the relatedTo field. They should be in Contact/Lead/User Id field. You can add the Account to the relatedTo Field.
      Email a screenshot of your process builder to and I’ll have look to make sure the tool is working as expected.

    • Great question. Yes it does!
      It’s harder to find the ID of lightning email templates. If you know how to run a SOQL query you can use “Select UiType, Name, Id, DeveloperName From EmailTemplate”.
      We will update the next version to search on names as the “Unique” or API/Developer name of email templates are different for lighnting. So it will now match on names as well.

  2. Hi,

    When I am attaching the email template Classic or Lightning Email Template

    The email body that is being sent and logged is showing Text Body with HTML with tags and only the signature.

    Its not using the template.

  3. Is there any option to dynamically add attachments? We have a custom object record which is conected via lookp up relation with a contact record and we would like to attach a file which is uploaded under files on this custom object to an email which should be sent to this related contact…

    • Yes. You can add files/attachments if you specify their id. You will need to create a flow to find the content or content version id and then you can include it in the email.

  4. Thank you for making this available!

    I get the following error when trying to use the Email Template ID:

    Error element myRule_25_A2 (FlowActionCall).
    An Apex error occurred: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []

    I went ahead and used the Email Template Unique Name and it worked, except it shows not tracked on the activity. This is tracked when using in a sandbox where I was able to use the id just fine.


    Thank you

    • Hi Brad,

      My first assumption is that the email ID is correct. They can be different from sandbox to production. That’s why we added in the template unique name feature.

      Using the template unique name just finds the email template Id for you. It does not disable logging activity at all.

Leave a Reply

Your email address will not be published. Required fields are marked *

Request Callback