Salesforce: Setting Up an Email Alert

Admin Admin

Salesforce can be intimidating to the beginning administrator. Let’s say you’re setting up your Support system, and you want to configure Salesforce to send emails when certain conditions are met on your Cases. One might go to the Setup console, expand the Email tab and be confronted with no fewer than 19 nested items, one of which has nested objects of its own. Of course it’s not really as scary as it looks, but it isn’t a one-step process either. You’ll need to configure a few different items to work in tandem. Let’s take it one item at a time.

Email Templates

To start at the top, the Email Template is the actual body of the email message that you want to send. Looking ahead, you’ll attach this Template to a process so that Salesforce knows when to use it, but for now, we’ll just start by building a new Template. As you probably know already, open your Salesforce Setup console through the gear icon on the upper right of any Salesforce page, assuming your account has the permissions. Find your Email Templates page either by browsing under the Email tab on the list to the left of the Setup console, or by typing “templates” in the Quick Find search box – generally the fastest way to find anything in Salesforce. From the Email Templates page, click the New Template button in the upper center.

Your first choice will be one of a few formats. If you have a Letterhead configured, you can build your Template as HTML against the background, but for now we’ll just go with Custom, which will let us build HTML content without needing a Letterhead. Following this, you’ll be asked to give your new Template a name, along with an encoding language. There’s generally little reason to change the encoding away from its default, but you will probably want to check the Available For Use box before proceeding.

Now you’re already into the actual content editor, where you’ll build the email using regular old HTML script. Of course, if you don’t need or know HTML, you could just create the template as plain Text and not worry about it, but of course HTML allows you rich formatting options.

Here’s the interesting part: You have a pair of dropdown menus above your editor, next to a text field. These are here so you can script dynamic fields into your email, from a selection of many, many Salesforce items. Since we want to make this Template pertinent to cases, we’ll select Case Fields from the Field Type dropdown, and then select a field from the second so we can copy the field’s tag from the text box. For example, here we’ve added {!Case.CreatedBy}, which will appear in the email as the logged creator of the Case. In this example, it is also important to include the Case ID number by adding {!Case.Id}, as Salesforce uses this ID number to identify email traffic as belonging to a particular Case.

Once you’ve finished your HTML message, the last stage of the Email Template will ask you for a text version. This is for email clients that don’t support, or are configured not to display, rich HTML content. You still have a few fields that can give you dynamic content to include, but chances are you’ll just want to click the Copy Text From HTML button to convert your existing HTML template into a plain version. For the text version, you won’t need to add line break tags and such; it will appear as-is. You’ll be able to copy this text from the HTML again later on as you make changes. Once you like what you have, click Save, and you’re all set with a complete Email Template. It might be helpful to name your Templates with some convention that makes their purpose easy to identify later – like in this case, name it something starting with Support.

Email Alerts

One of the more challenging-to-grasp aspects of this email alert process at first is that you’ll need to attach your Email Template to another item called an Email Alert. In the following step, you’ll create a Workflow Rule that will refer to this Email Alert, rather than directly to the Template. The Alert contains information such as who the email’s recipients should be.

Start with a name for the Alert (there’s no reason not to make this the same as, or very similar to, the name of the Template), select the pertinent Salesforce object from the dropdown (Cases for this example) and select the Template you just created. Now we’ll move on to the email’s recipients. Having selected Case as your object, the Recipient Type dropdown will have a number of selections based on Cases, such as the Account Owner, or whoever last modified the Case. If you want to send this email to the Case holder, you’ll choose Related Contact. Then move the “Related Contact: Contact Name” from Available Recipients to Selected Recipients. If you’re sending internally, select Owner and then Case Owner instead to send to the case’s handler, or you can even just select a User to email someone specific. You can choose any number or mixture of recipients as you see fit, like if you want someone internal to receive a copy of the email going out to the Case holder. Finally, you can also add up to five additional addresses manually in the text box below.

Lastly, you’ll have the option to select the email’s From address: either the current user, or the Default Workflow User specified elsewhere in Salesforce’s settings. If you have Email-to-Case configured, you should be able to use your routing address as well. Once you’re content with your selection of recipients, click Save.

Now that your Email Alert is configured, if you click its name in your Email Alerts list, you’ll come to this properties screen. In addition to being able to view and edit its various properties like what Template it’s using and who will receive it, you’ll get a handy look at what processes are using this Alert, which will usually be a Workflow Rule. Which brings us to the last step in our process…

Workflow Rules

You may have worked with Workflow Rules before, as they have many functions outside of sending email notifications. In essence, they’re a collection of “When Thing A happens, do Thing B” instructions. In this case, let’s say Thing A is that a Case has been created, and Thing B is that you want to send an email notification to a team member. As we have in prior steps, we’ll start by clicking the New Rule button in the upper center.

First you’ll be asked for a Salesforce object; again, we’ll choose Cases. Then, set a name and description for this Workflow Rule. You may want to be descriptive here, as you’ll likely have many Workflow Rules performing lots of different functions throughout your Salesforce environment. Again, maybe start the name of the rule with Support, and have the description mention that this is a rule to send an email to a user when a new Case is created.

Next you’ll set when this rule is supposed to run – on creation, whenever it’s created or edited, or whenever it’s created or edited in a way that triggers the following criteria. In this case, we’re sending an email to notify someone of a new Case, so we should only need to run this task when the Case is created.

We still need to specify another specific criterion in order to save the Workflow Rule, though. For this example, the only thing we’re looking for is that the Case has just been created, so we know that the Case will ostensibly have the New status. Expand the first Field dropdown and select “Case: Status.” Set the Operator field to “equals.” The last field needs a specific value; you can just type “New” in this case, but if you’d like to browse a menu that has all of your options, you can click the button that looks like a sheet of paper with a magnifying lens over it. This will let you pick out the value you want and drop it easily into the Value field without having to worry about whether you typed it properly.

Once you’ve set up these Thing A criteria, it’s time to tell the Workflow Rule what Thing B is. Sending this email will be an on-demand thing rather than a timed thing, so look under Immediate Workflow Actions and select the Add Workflow Action dropdown. You’ll see here that you have the option to create a new Email Alert on the fly, but since we’ve created ours already, we’ll choose “Select Existing Action.” Search Email Alerts and you should see the Alert you created a moment ago; pick that, click Save, and you’re all set.

You may have to activate this Workflow Rule manually once you’ve created it, though. From your Workflow Rules menu, just click the Activate link on the left side of the Rule you just set up. This Workflow Rule should now be ready to send the email notification you’re looking for.

Putting it All Together

To recap again: First you’ll need an Email Template, which is the email you want to send. Then you’ll need an Email Alert, which tells a Workflow process who should receive the Email Template. Then you need a Workflow Rule to tell Salesforce to execute the Email Alert whenever some specific conditions are met. Now that we’ve done all this, Salesforce should have everything it needs to send off a quick email notice to your chosen team members whenever somebody has created a support Case. Now that you’ve been through this, it shouldn’t be too challenging to configure some more Alerts, like sending a similar notification to the customer if you’re using email-to-case, or to notify your support team when the Case Owner has changed. It might be a non-trivial amount of work to set up, but the sky is the limit. Good luck!