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. [email protected], [email protected]
  • 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 use 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

Limitations

  • 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.

Demo




38 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 [email protected] 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…

  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.

    Thoughts/Suggestions….?

    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.

  5. Thanks so much for sharing this! I followed the instructions and got it working perfectly. I used this in a NonProfit edition org (which is an Enterprise Edition) and deactivated the NPSP Email Acknowledgement Workflow and replaced it with this.

    Worked like a charm!

  6. Is there any way to use this just to log existing emails automations sent without having to recreate them all inside process builder or flow? If so I’d love a newbie demo of how to grab this info.

  7. Hi,

    I’m very excited about this app. But somehow when i use a classic e-mailtemplate with merge fields. The merge fields are not filled in the sended email or logged activity.
    Any suggestions how to correct this?

    • It works the same way. Make sure you follow the instructions carefully if you are not seeing the email work correctly.

      A common mistake is specifying a subject and an email template Id. Salesforce doesn’t allow you to do both

  8. First of all, this is UNBELIEVABLY GREAT. Thank you so so so much for making this available! The fact that it works with the native email tracking too is awesome.

    Second, it seems it won’t pull in Lightning Email Template attachments, so I tried using the Content Version ID, but must have that part wrong as I keep getting an Unhandled Fault error now. Do you have any tips for getting attachments sent? We’re trying to use a field with the attachment content version ID and reference it, just like the email template id can be referenced. Thanks again!

    • Hmm… It might be something to do with how Apex works with the newer lightning emails. I would first confirm that you are using ‘files’ which are stored in the database as content. How do you find the content version id?

      Secondly if that falls I would create a classic email template and just get it working 🙂

      • I added a formula field on the Content Version record to display the Content Version ID. I grabbed it there. However, I tried it with a classic email that had an attachment and it worked flawlessly. I can’t even tell you how amazing this tool is. Best add on I’ve used maybe ever in SF for the value it delivers. THANK YOU!!

  9. Hi,

    that’s a cool piece of software!

    When using an email template, the merge fields are empty. When I use a regular email alert in the same process the fields are filled.

    What can be the problem here?

    Br,

    Lukas

    • Please triple check you have followed all of the instructions. Salesforce is a bit fussy at times.

      Check you have a related to id and make sure your don’t specify a subject or body and an email template.

Leave a Reply