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 https://thedetaildept.com/2012/06/20/difficulties-using-email-salesforce/ 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.
You want
Think this is possible using Salesforce? Think again.
The Letterhead in Salesforce is only 600px wide! Oh dear!. https://success.salesforce.com/answers?id=90630000000grr3AAA. 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:
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.
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! (https://success.salesforce.com/ideaView?id=087300000007SHhAAM) . 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. http://salesforce.stackexchange.com/questions/1243/setting-a-from-address-in-singleemailmessage.
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:
Any others?
I like working with Visualforce email templates, even though they are more difficult. You can do things like
Reference fields in any relationship that you can get to from the related to record - eg
{!relatedTo.Objecta__r.ObjectB_r.ObjectBField__c}
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. https://www.campaignmonitor.com/guides/ (especially Designing for the Inbox).
HOWEVER! Visualforce email templates take time! Allow yourself time!.
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.
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}"/> |
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> </div> </apex:outputPanel> <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> </div> </apex:outputPanel> |
See some more ideas on this here http://salesforce.stackexchange.com/questions/18603/rendering-output-panel-if-list-is-not-null and http://www.laceysnr.com/2011/10/using-rerender-to-render-one-solution.html
Going one further than above - if you have a list of items some of which are conditional, then use this.
<ul> <apex:variable var="vargoogle" rendered="{!relatedTo.ShowGoogle__c = true}" value=""><li><apex:outputlink value="http://google.com">Google</apex:outputlink></li></apex:variable> <apex:variable var="varbing" rendered="{!relatedTo.ShowBing__c = true}" value=""><li><apex:outputlink value="http://bing.com">Bing</apex:outputlink></li></apex:variable> </ul> |
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 directly before the outputlink.
Display the event start date on your email.
<p>Start Date: <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 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
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: <apex:outputText value="[JUST PUT A SPACE HERE]{!relatedTo.Campaign.StartDate}" /></apex:outputText></p>
<p>Start Date: <apex:outputText value=" {!relatedTo.Campaign.StartDate}" /></apex:outputText></p>
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).
https://instance.content.force.com/email/templaterenderer?id=XXX&recipient_type_id=XXX&base_href=https%3A%2F%2Finstance.salesforce.com&related_to_id=XXX&preview_frame=previewFrame&render_type=REPLACED_HTML_BODY
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!).