Custom Send Email Button on Custom Objects

  • Go to Setup | Create | Objects.
  • Select your Custom Object.
  • Go to the Custom Buttons, Links and Actions section.
  • Click on New Button or Link.
  • Create a New Custom Button.
  • Select the Display Type as Detail Page Button.
  • Select the Behavior as Execute JavaScript.
  • Select the Content Source as OnClick JavaScript.
  • Include below code:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}

window.location = '/_ui/core/email/author/EmailAuthor?rtype=003&p3_lkid={!CustomObject__c.Id}&retURL=/{!CustomObject__c.Id}&p5={!$User.Email}&p24="{!CustomObject__c.To_Email__c}&template_id=00X90000001FCj4';

Note: If the custom object holds some of the contact details then you would need to use the values from custom object, not the contact object.

Save it. Edit the Page Layout of the Custom Object and drag this button on to the Page Layout under the Custom Button section.

The information shown below are the parameters that can be added in the URL. Fields that are mark with asterisk are always needed in the URL.

Parameter Name Parameter Value
p2_lkid To (can be Contact or Lead Id)
p3_lkid Related To (usually the parent record Id)
p4 CC
p5 BCC
p6 Subject
p23 Email Body
p24 Additional To
Template_Id Salesforce email template Id
retURL Redirection page when cancel button is clicked