Skip to main content

Quick Tips: All about sending emails from Salesforce (with advanced features)

Emails are still a very essential part of our day to day communication. Be it an internal communication within the organization, or across organizations or between customers and organization, emails are one of the key communication mechanism (let's not debate on pros and cons here). Quite obviously, Salesforce provides various options to send emails to internal and external recipients. In this post I'm trying to cover all the essential points (briefly) involved in sending emails from Salesforce.

Defining Email Templates

First and most important aspect regarding emails is ability to create email templates within Salesforce. This is without doubt one of the most used aspect related to sending emails. Email templates help administrator create pre-defined email templates within Salesforce. This helps in providing business approved and verified templates to system and users. As a result, all outgoing communications are consistent. Also, any correction/ improvement incorporated is automatically available to all it's users. Furthermore, email templates have ability to embed merge fields (values which can be substituted by attributes of given record), for example, automatically populating customer's name and order number on outgoing email.

Salesforce allows creation of three types of email templates:-
  1. Text:- most basic of the options. As name states, it just contains plain text email content. 
  2. Custom (without letterhead):- allows administrators to create email templates using HTML to define beautiful and elegant email templates
  3. HTML (with letterhead):- this is similar to previous option. Administrators can define a letterhead (letterhead defines common email header and footer contents) and compose email template using rich text editor
  4. Visualforce:- most advanced version of email templates. This is created by developers using Visualforce to address most complex email template requirements (for example, generating different UI based on data attributes). It provides developers full control over the email template UI. It also enables developers to dynamically generate attachments (PDF, CSV etc.) along with the email. For e.g. if you want to automatically generate Invoice PDF and send to customer, Visualforce email templates can be really handy
More details email templates will be covered in separate post.

How to Send Emails?

Thankfully, Salesforce provides many ways to send emails from Salesforce and yes, one of them is via code. Interestingly, there are so many configuration based options for sending email that code is really required for specific requirements.

Send Email Manually

Most certainly, the first option is to be able to use an email template; if required, make modification; and then send the email. Emails can be sent from pretty much any standard/ custom object for which "Activities" is enabled.
Usage Scenario: Need to send ad-hoc email to customers

Send Email via Workflow/ Lightning Process builder 

Workflows and Lightning process builder processes are the swiss army knife of automation within Salesforce platform. Certainly, these can be setup to send emails using email templates.
Usage Scenario: Send an email to customer on their birthday or marriage anniversary; workflows/ process builders can be setup to automatically send emails for this scenario.

For more details on Email actions refer Email Alert actions.

Send Email via Flow

Flows provide developers capability to automate processes by create custom user interface along with custom business rules without code. It's definitely a very helpful approach as it helps in creation and maintenance of custom UI. As a possible flow action, developers can send email from a Flow.

For more details on sending emails from Flow read Flow Send Email element.

Send Email via Approval Process

Similar to previous option, Approval processes within Salesforce allows users to send email notification on different approval steps.
Usage Scenario: Send email to each approver upon assignment for approval or want to notify submitting user about acceptance/ rejection of the approval request.

Send Email via Case Escalation Rule

Case escalation rules help organizations escalate cases exceeding Service Level Agreement (SLA). Upon escalation, administrators can configure escalation rules to notify specific users.
Usage Scenario: Notify Customer Service Director upon escalation while assigning escalated case to supervisor.

Send Email for Report/ Dashboard

Sales and customer service managers mostly want to look at weekly/ monthly dashboards for their business needs. Often the expectation is to get the details automatically, without having to login into Salesforce. This can be achieved by scheduling reports/ dashboards (refresh dashboard and email) to be sent via emails.
Usage Scenario: Send Sales pipeline stats to Leadership on weekly basis

Send Email via Apex Code

Last and mighty, Salesforce allows developers to programmatically send emails to customers/ users or any external email ids as well. Being a programmatic approach, this provides maximum control to developers. Developers can control the recipients, email content, attachment etc.
Usage Scenario: Create a custom screen to pull data based on custom filters and email data to customers


There are more feature specific email settings, wherein Salesforce sends email to designated recipients (mostly internal) for example, assignment rules, contract expiration notifications, chatter etc.

Advanced features


Send Email using common mailbox a.k.a. Organization wide addresses

As a general customer service practice, organizations prefer to use common mailboxes to communicate with clients, for example, customerservice@abccorp.com or support@xyz.com. To achieve this, Salesforce allows creation of Organization wide email addresses, which can be used to send emails from Salesforce using common organization mailboxes.

For more details on creating Organization wide email addresses read Organization-Wide Addresses: Let Users Send Email from Salesforce Using a Common From Address

Send default content within footer of outgoing emails (Organization-Wide Email Footer)

Many organizations prefer to include some legal/ copyright content within all emails going out of organization (using official mailboxes). Generally, this is setup within email servers. However, when sending emails via Salesforce, email server settings do not apply.

In order to get the same features, Salesforce provides feature known as Email Footer (more than one can be created). This allows administrators to specify the common legal content within email footers and use them for outgoing emails. More than one organization wide email footer can be created.

Send email using external mail server (Email Relaying)

In this world full of spam emails, lot of organizations block incoming emails from unknown sources (including Salesforce). There can be situations where customers complain that they are not receiving emails (being sent from Salesforce). This is generally due to the fact that emails are being blocked by their mail server. Customer's mail server may have been setup to accept emails from your organization, but might be blocking emails from Salesforce. In such scenario, the solution is to setup Salesforce to send emails from your mail server, also known as, Email Relaying.
Email Relaying allows Salesforce to route all outgoing emails via your email server. This helps ensure:
  1. higher email deliverability and reduce email bounces
  2. keep backup copy of outgoing emails for legal/ compliance reasons
  3. incorporate additional content check
  4. run third-party email softwares (content filtering/ anti-virus) on outgoing emails

[Lightning Experience Only] With Summer '16, you can also setup your Salesforce org. to allow users to use external email providers (currently Gmail and MS Office 365 are supported). So, once enabled, users can provision Salesforce by logging in with their third party account (Gmail or MS Office 365) to be able to send emails from their external account.


Sign Outgoing emails with certificates (DMARC compliance)

With ever rising security issues on internet, it is becoming more and more difficult to rely on emails. For matters concerning privacy and confidential information, emails have become a very risky tool. It is equally problematic for email senders as they are equally unaware whether the emails sent by them are being trusted.

Thankfully, there are some standards to secure outgoing emails and ensure that recipients can validate the authenticity of emails. A few notable standards are:
Salesforce allows administrators to setup DKIM keys for outgoing emails. This process also allows outgoing emails to be DKIM and DMARC compliant.

To know more about setting DKIM keys read Create a DKIM key

Important points to remember

  1. Email limits restrict sending emails to 5,000 external email addresses (does not include lead/ contact/ person accounts/ users and emails sent manually) per day (refer Email limits)
  2. Daily limit for emails sent through email alerts is 1,000 per standard Salesforce license per org (except free Developer Edition and trial orgs)
  3. Overall org daily limit for sending emails is 2,000,000. This limit applies to emails sent through email alerts in workflow rules, approval processes, flows, processes, or the REST API.
  4. Unlimited emails can be sent to internal users
  5. Maximum number of recipients is limited to 
    1. TO - 100
    2. CC - 25
    3. BCC - 25

Comments

Popular posts from this blog

Quick Tips: Salesforce default Images

Well, I'm sure a lot of you still rely on using out of the box salesforce images for displaying quick icons within formula fields or even using them within your Visualforce pages. Lately, I realized that a lot of earlier resources are no longer accessible, so I tried to quickly extract all images from Salesforce CSS files and provide a quick reference here. Please note, I've referenced all images from SF servers directly, so if anything changes, the image should stop rendering here. As these images are completely controlled by Salesforce, and in case they change anything, it might lead to image not being accessible. Image path Image /img/samples/flag_green.gif /img/samples/flag_green.gif /img/samples/flag_red.gif /img/samples/color_red.gif /img/samples/color_yellow.gif /img/samples/color_green.gif /img/samples/light_green.gif /img/samples/light_yellow.gif /img/samples/light_red.gif /img/samples/stars_100.gif /img/samples/stars_200.gif /img/samples/stars_300.

Lightning: Generate PDF from Lightning components with in-memory data

I'm sure as everyone is diving into lightning components development, they are getting acquainted with the nuances of the Lightning components framework. As well as, its current limitations. Being a new framework, this is bound to happen. Although we have our users still using salesforce classic, we have started using lightning components framework our primary development platform and Visualforce is considered primarily for rendering lightning components within Classic Service console. Recently, while re-architecting a critical module, we encountered a problem wherein we needed to generate PDF from lightning components. Now, being Javascript intensive framework, it has limited room for such features (may be included in future roadmap). As of now, there is no native feature within the lightning framework to do so (at least I didn't find anything). Common Scenario - Create Visualforce page to retrieve data and generate PDF For scenarios where the data exist within Sa

Quick Tips: Setup SFDX Manually without Admin access

We all have faced challenges while working in different enterprise environments, where there may be lot of controls/ checks/ red-tape to get by. In such situations, getting access to simple tools (even git) can take lot of time. Note: This tutorial is to be followed at your own risk, as it may not be complaint to your organization's IT policies. What is SFDX? SFDX is a command line utility for managing salesforce builds/ deployments. Being command line, it can be easily embedded to automation chains, to help build fully automated build and deployment processes. To get started, refer  https://trailhead.salesforce.com/en/content/learn/trails/sfdx_get_started Setup SFDX on Windows machine without admin access As you may have already realized, SFDX installation needs admin access to one's machine. Which may be a luxury a lot of developers may not have. So, i tried to provide a step-by-step guide to setup SFDX on your computer without any admin access Steps: Note: