Tutorials / Admins

Sending and Logging Email Alerts As An Activity: Here’s Our Solution!

By Daniel Howell

One of the most popular ideas in the Salesforce community, outstanding for 11 years with  47,300 Points and 4,750 Votes, is the ability to send an email alert and record it in the activity history. There are workarounds available, such as saving a completed task, but none of these saves the specific content of the email.

This can cause major problems:

  • If you need to store a copy of the email for compliance reasons email alerts become an unattractive option to use.
  • You can’t use an email alert if you need to store a copy of the email for compliance reasons.
  • Mistakes in setting up automation like workflows or process builders could be resulting in numerous emails being sent at the wrong time without anyone knowing.
  • If a user wants to see the content of the emails sent or the specific use of merge fields there is no history. We think it’s really important to be able to log these emails with their content.
  • There’s no option to dynamically add an attachment.

The Solution is a Free App

Salesforce has the ability to log emails sent using Apex code. GravityLab is an NZ Salesforce partner and have created an app that allows you to use that Apex code with the simplicity of an Email Alert. You can call it from process builder or flows,  pass through the relevant recipient id and email template, and the email is sent with the activity logged.

Extra Benefits

The app also opens up other possibilities beyond just logging the activity. You can:

  • Send emails linked to related records.
  • BCC and CC to your heart’s content.
  • Specify the email subject and body without an email template.
  • Dynamically add attachments.
  • Respect the user’s email opt out settings, or override them for transactional emails as required.
  • Better reporting – Storing emails as activities means you’re able to report thoroughly on what emails are going out each day.

Use Cases

  • Related Records – Add a process builder that sends an email when sales is won on an opportunity and link it to a related object like a contract.
  • Dynamic Recipients – Use a formula field to get an email address from a different object to send to. Currently, you can only refer to email type fields on the object, which means you’d need to use triggers or flows to bring an email address onto the object. This way you can make the email address used dynamic.
  • Multiple Recipients – Send email to Opportunity team – If you can fill in a list of emails on an opportunity team, you can refer to it when an opportunity is closed, and CC all the users in that team on the email.
  • Dynamic Emails – Integrate email processes into flows without having to use email alerts, and use values from that flow. For example, you could write a message in the flow which is then sent as part of an HTML template saved in a custom setting, and then choose the attachments to send as part of that message from a picklist or checkboxes.

To download the app and view the instructions you can visit the GravityLab’s website here: Salesforce Send Email Tool.

Use process build, flow or apex to send an email

Example of the Salesforce Send Email Tool in  a Process Builder


Example of the Salesforce Send Email Tool in  a  visual flow

See the sent email in the activity feed

The Author

Daniel Howell

Daniel is a Salesforce Consultant and enthuisiast at GravityLab in NZ. He designs best-practice Salesforce architecture to deliver real results.


    May 06, 2019 4:06 pm
    Great, thanks! But now with Einstein Activity Capture this is not so important anymore, although the emails expire after 6 months by default I think...
    May 06, 2019 4:11 pm
    Really interesting. Do you know if you can / how you can adjust the sender of the email? depending on criteria I want the email to come from a different staff member and I use multiple email alerts to accomplish this. Would I be able to do that with this app?
    May 07, 2019 5:20 am
    Danny - If you have multiple organisation wide email addresses for each user then you could just add the user's email address to the "OrgWideEmailaddress" field.
    Daniel B
    May 07, 2019 9:22 am
    What is the name of the app? I searched Gravity Lab on the App Exchange and it didn't appear.
    Danny Cohen
    May 07, 2019 8:35 pm
    Thanks Daniel. Yes, we do have that and currently have multiple email alerts set up to send from the right person. But for each email I want to send from the flow I have to set up 10 email alerts that are exactly the same except who the sender is. I was wondering/hoping that this would allow me to use a variable for the senders name/email.
    May 19, 2019 11:00 am
    Can we capture the activity on the custom object?
    August 02, 2019 8:31 am
    Is there a way to assign multiple ContentDocuments to 1 email? I have tried to send comma delimited string into the field, and get the error "Error Occurred: An Apex error occurred: System.QueryException: List has no rows for assignment to SObject ", and its not possible to select a collection variable in the field. Ideas?
    August 31, 2021 7:30 pm
    I'm fairly new and do not know much about coding in Salesforce. I installed the package from Gravity Labs, but it will only send 10 emails due to a hard limit within Apex. Any way around this without knowing how to code Apex?
    February 28, 2022 1:36 pm
    if we are sending an automated email to the customer of the the case via email action in flow, I need that mail to be visible in feed of the case. email is being sent but am not able to see the email in the feed
    Ryan Golembiewski
    April 18, 2022 11:28 pm
    Here is the Link to the Gravity Lab Send Emails AppExchange Listing: https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3A00000FMWT8UAP
    February 08, 2023 4:45 pm
    Thanks for making this tool available. One of the challenges I'm running into using Email Templates is that my merge fields are not being populated in the Subject line and within the Body of the email. What is causing this issue?

Leave a Reply