Email Template Shortcut Buttons
A client of ours got frustrated with having to click on Send an Email, then Select a Template, and finally Select the right Contact(s) before hitting Send on a very common type of email. The email was still sent on a discretionary basis by staff so we couldn’t automate it with a workflow rule. The client asked for a special button to be put on the page that could open up the correct email template and automatically select the correct contacts. After some searching on the Salesforce.Com Developer Forums, I found this little gem of JavaScript code.
I adapted the code to the following:
location.replace(’/_ui/core/email/author/EmailAuthor?
retURL=/{!Opportunity.Id}
&p3_lkid={!Opportunity.Id}
&p2_lkid={!Opportunity.Registrant_Salesforce_ID__c}
&p2={!Opportunity.Registrant_Full_Name__c}
&p24={!Opportunity.Billing_Contact_Email__c}
&template_id=00XX99234365′);NOTE: Remove the linebreaks if you cut and paste this code.
I put the above code into a Custom Button on the Opportunity Object. The Button behavior should be set to Execute Javascript and the Content Source should be set to OnClick JavaScript.
In the above JavaScript code, the following variables are represented:
- retURL = URL that the user is returned to if they click Cancel on the message
- p3_lkid = The ID of the record that this email should be associated with (the WhatID)
- p2_lkid = The ID of the person that this email should be associated with (the WhoID)
- p2 = The name of the person that this email should be associated with
- p24 = The email address of anyone you want as additional TO’s on the message
- templateID = The Salesforce ID of the email template that you wish to use



