On this page:

When I first started using Salesforce I thought it would be great for emailing. OMG how wrong was I! So I wrote a blog post and sorry to say that 5 years later, the emails have NOT gotten any better. And to top it all off we were going to have a great new Quill HTML editor, and now that looks like it's going to be a complete bust - see Rich Text and HTML Editors, and now even the simple Mailchimp for Salesforce integration is broken, so we do NOT have even a remotely reasonable solution for emailing from Salesforce. And then there is the different email integration tools now for Gmail and Outlook, that I have tried to steer clear of until they are at least in GA and I have a good client that is willing to try them. 

Email Templates Letterheads and Footers. 

You want

  • A consistent email signature 
    • from all staff
    • for all communications
      • from outlook or gmail
      • from a single, hand crafted email via Salesforce
      • from a single, mail merged email via Salesforce
      • from bulk email out of Salesforce
  • A disclaimer on the bottom of the email, that doesn't overshadow the whole email. 
  • A logo in the signature (obviously not an attachment). 
  • Emails to be able to be sent as HTML and / or Text
  • Emails to look like they have been sent from Outlook or Gmail.

Think this is possible using Salesforce? Think again. 


The Letterhead in Salesforce is only 600px wide! Oh dear!. See Creating a Branded Email Letterhead with a Logo for how to create the Letterhead.

Email signatures don't come out on letterheads, but email footers do. The email footer is just text at the bottom of the email, so is wider than the HTML email template (see a terrible example of that here). If the signature won't send when using templates why would the footer send? It makes no sense at all. So email footers are basically useless. 

Your HTML email signature can only be 1300 characters of HTML - that is not a lot. 

You can't use your finely crafted Email signature in HTML email templates. You can only make up a pseudo signature with Merge fields from the User Object. 

You can't add text to Custom or Visualforce Emails when sending them, so they are only good for strictly formatted emails, OR place an email text box on the object, and clear the box with a workflow when the email has been sent - very clunky and user's don't like it. 

Email footer (or disclaimer) text is the same size as the email text is - and you can't change it.


So, here is how I got around it, and I'm not sure it is the best solution at all:

  1. Remove any Email buttons from the contact layout.
  2. Create a custom field on the User Object as a rich text field to store the Email signature - annoying because the user is expecting to update their email signature in their main user settings, not on the user record. 
  3. Create a global Label containing the disclaimer text (it just fit). I'm not sure this is the best way, but it is a place to store it only once for the org. 
  4. Create a formula field on the User Object to reference the disclaimer global label. 
  5. Create a very basic email template with the Email Signature field and the Disclaimer field from the User Object with optional Dear Contact Name. (The annoying part about this is what do you put in the subject? I haven't quite worked that one out yet). 
  6. Bonus - make the disclaimer text in 8pt font. 
  7. Create a Quick Email button on the Contact Object using the tips from this support article to create an email based on the new template you have just made. 
  8. Add the button to the Contact layout(s). 

Now, whenever the user wants to email the contact, they click on the Quick Email button, and the email contains a reasonable looking HTML footer, small disclaimer text, and all lined up. It is still stupidly 600px wide, but at least it looks consistent. 

Emails from Opportunities


How do you even do a salutation (eg Dear Mary) in an automated email that comes from the Opportunity? The only way I have found it to work is to create a field for Primary Contact on the Opportunity. Optionally have a trigger to automatically set it from the Primary Contact in Contact Roles. Create a formula field (I called it Dear__c) that gets the First Name from the PrimaryContact__c field. 


The email can come from the running user or the workflow user, not the owner of the opportunity - unbelievable! ( . How do you ensure that an automated email comes from the owner of the opp? (The only way seems to be send the email from the contact record and relate it to the opportunity - stupid!). 

One possible work around that has been suggested is to create a separate workflow for each user. This would also require a separate org-wide email address for each user, and potentially even a separate profile for each user to stop other users using that org-wide email address (as you can only assign org-wide addresses to profiles). Wow, what a maintenance nightmare. This is really not an option.

See Salesforce Made Easy: Organization-Wide Email Addresses - Addressed for setting up Org-Wide email addresses. 

And don't think using Apex emails or triggers can work around this - the only options in Apex emails is to use Org-Wide addresses also.

I can't even see a way around it using a third party email service like Sendgrid because that just sends the email that is created within Salesforce, and there is no way to create it within Salesforce as coming from the Owner of the Opportunity. 


Now, you could say that this is by design, as you don't want automated emails coming from a person... but there are still good business reasons to do this - so the fact that Salesforce completely stops us from being able to do this, is not great at all.

And don't think Conga or Drawloop will help with this. Drawloop uses the standard email functionality. Conga has it's own but only allows it to be an Org Wide Email Address


"I want an automated email to go out to my clients when their contract is due for renewal - 2 weeks before renewal. As our organisation prides ourself on our personal customer service, I want the email to come from me".

Not possible. 

A few options:

  • Create a workflow that sends a task to the Owner of the record (Johnny) asking them to send the email. What if Johnny forgets? Back it up with reporting to ensure things don't slip through the cracks. Trigger to set the record to a status that makes it appear in Johnny's view of deals he is working on?
  • Send an automated email from customerservice@ with the contact details of the Owner or the record letting the client know that their contract is due for renewal and that Johnny will be in touch soon. Also send the task to Johnny so he can make contact. This at least means that it is up to both parties to initiate the contact.
  • Use an outbound message service and a third party messaging api like Sendgrid or Mandril. 

Any others?

Emails from Workflows

  • Emails triggered by workflows can not come from the Owner of the record, only the current user that triggered that workflow (useless, because it could be anyone) or workflow default email address. 
  • They can't have a signature on them, so you need to make up a generic signature based on the record owner Name, Email and maybe Phone fields.
    • I would suggest put a closing line of If you have any queries, please do not hesitate to email me by email at or by phone on 0X 9999 9999.
  • They DO NOT save an activity on the activity history. This is really stupid (see The only thing you can do is create a completed task against the record to say that it was sent. However, that just takes up data storage for no valid reason. 
  • The fields on the email must only come from the one object. 
    • So use formulas to reference fields in (eg the First Name from the Contact associated with a Contract). 
  • Always set a condition on the workflow to send only if Email_Sent__c = False. Then on the workflow do a field update to Email_Sent__c = True. That way the email won't get sent again as the criteria won't match. 

Email Templates


I like working with Visualforce email templates, even though they are more difficult. You can do things like

  • Custom or complex layouts
  • Reference fields in any relationship that you can get to from the related to record - eg 

  • Show conditional text in your email - one email template for many uses
  • Have control over the formatting without using the shitty email rich text editor (see my rant on Rich Text and HTML Editors). 

I have a standard layout that I use (I may publish it one day, so if you want it, get in touch and I will send it to you). 

Remember, you have to use inline CSS as you would in any email template. I recommend the resources at Campaign Monitor about how to create beautiful email templates. (especially Designing for the Inbox). 

HOWEVER! Visualforce email templates take time! Allow yourself time!. 

Visualforce tips

Custom Settings

Store details that are used in multiple email templates in Custom Settings - eg, you have a knowledge base article that you refer to regularly - store that in a custom setting. If the KB article link ever changes, you only change it in one place. 

Rich text

Create fields in your records containing a rich text area where you want the standard email contents to go - eg if you have an event set up in Campaign, then have the EventBlurb as a field on Campaign. Add it to the email template with this code. 

<apex:outputText value="{!relatedTo.Campaign.EmailBlurb__c}" escape="false"/>


Create a URL field on your object. Put the URL of the externally available document image into the field. (See Creating a Branded Email Letterhead with a Logo). 

<img src="{!relatedTo.Campaign.EmailImage__c}"/> 

Conditional text

display a paragraph on your email if X = true - eg if the Campagin start date is upcoming, then put the how to get there blurb in, otherwise put the please give us your feedback blurb. Use this code. Only one of the paragraphs will display. 

<apex:outputPanel id="upcoming" rendered="{!relatedTo.Campaign.isUpcoming__c}">
<div style="font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; color:#000; font-size:16px;">
<p>Please find the details of the upcoming event....</p>
<apex:outputPanel id="upcoming" rendered="{!NOT(relatedTo.Campaign.isUpcoming__c)}">
<div style="font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; color:#000; font-size:16px;">
<p>Please provide your feedback on the event....</p>

See some more ideas on this here and

Conditional HTML elements

Going one further than above - if you have a list of items some of which are conditional, then use this. 

    <apex:variable var="vargoogle" rendered="{!relatedTo.ShowGoogle__c = true}" value=""><li><apex:outputlink value="">Google</apex:outputlink></li></apex:variable>
    <apex:variable var="varbing" rendered="{!relatedTo.ShowBing__c = true}" value=""><li><apex:outputlink value="">Bing</apex:outputlink></li></apex:variable>                                                                        

How cool is that! Thank you for this suggestion on Salesforce Stack Exchange


You need to output a number in a specific format. 

<apex:outputText value=" {!FLOOR(relatedTo.MyNumber__c)}"/>


Display a clickable link on your email. This one is to a knowledge base (or it could be to your website) showing how to get to us for attending the event, and it only displays if the event is upcoming. 

<apex:outputlink rendered="{!relatedTo.Campaign.isUpcoming__c}" value="{!$Setup.HelpDocs__c.HelpDocLink__c}">How to find us</apex:outputlink>. 

It seems you need to put an &nbsp; directly before the outputlink. 


Display the event start date on your email. 

<p>Start Date:&nbsp;<apex:outputText value="{0,date,dd'-'MMM'-'yyyy}"><apex:param value="{!relatedTo.Campaign.StartDate}" /></apex:outputText></p>

of course, format the date in your silly MM/dd/yyyy format if you want too (see this stack exchange article with a link to the docco and a full list of the date formats). Note the &nbsp; before the output text. Oh,  and if you want locale specific dates, you are out of luck it seems, based on this stack exchange article. (In my case, I want the dates to display in 

Dates and Times

Wow, I never knew this one. To display the date with time in your local timezone put a space before the field reference within the " ". Weird. 

<p>Start Date:&nbsp;<apex:outputText value="[JUST PUT A SPACE HERE]{!relatedTo.Campaign.StartDate}" /></apex:outputText></p>
<p>Start Date:&nbsp;<apex:outputText value=" {!relatedTo.Campaign.StartDate}" /></apex:outputText></p>

IF Statements

This example extracts the HTMLBody of the email if it has one, else the TextBody

<apex:outputText style="font-size:10px;float:left" value="{!IF(em.HtmlBody="",em.TextBody,em.HtmlBody)}" escape="false"/


You know when you are building an email template and you need to preview it thousands of times to see if it is displaying with all the correct data and formatting? Here's a URL hack that I discovered by accident (If you view source on the frame in the email preview, that's how you find this URL).
  • Replace the the two occurrences of instance with your instance - eg NA12, AP1
  • id=XXX - the Email Template ID
  • recipient_type_id=XXX - eg the Contact ID that this email is going to
  • related_to_id=XXX - eg the related Campaign Member record that this email is based off. 

Open the URL in your browser, make the changes in your email template then refresh this window. It works quite nicely. Then you only have to send a preview email to yourself when you are really happy that everything is working well. (eg, you have forgotten to make the images in the email publicly accessible, haven't you!).