您的位置:首页 > 大数据 > 人工智能

Salesforce: How to Send Email with Default Template?

2015-04-18 10:55 701 查看


Salesforce: How to Send Email with Default Template?

Send an Email is standard Salesforce functionality, if your Salesforce admin make the button visible in Activity Historyrelated list for that object page layout, user can just hit the button and enter email detail -- To, Additional
To, CC, Subject, and Body. Email should related to a record. Optionally, user also able to select a Template, where within template, email Subject and Body can be determined using merge fields. This will increase user productivity when user always send email
with the same format.

But, can we make user even more productive? When user hit Send an Email button, template will be auto select, andrecipients also auto populated based on field in the record.

Yes, this is possible to use custom button and URL hack, meaning there is no support from Salesforce and it maybe break one day if Salesforce change in their back-end.

Scenario: to send email from Opportunity record, template is auto-populate, email Related To auto related to the opportunity, Additional To auto populate from an email field in Opportunity, CC will come from another field and hard-coded with
another email address.

1. Create a custom button at the object





2. Let's analyze the script:

location.replace('/email/author/emailauthor.jsp?retURL=/{!Opportunity.Id}&p3_lkid={!Opportunity.Id}&p24={!Opportunity.Email_Custom__c}&p4={!Opportunity.Acct_Email__c},myemail@gmail.com&template_id=00X50000001FypB&p5=xyz');

another sample to implement this for Case:

location.replace('/email/author/emailauthor.jsp?retURL=/{!Case.Id}&p3_lkid={!Case.Id}&rtype=003&p2_lkid={!Case.ContactId}&p4=yujohan@gmail.com&template_id=00X50000001FypB&p5=xyz');

Explanation:

retURL : used when use hit Cancel button, page will be back to original report, in this case is Opportunity

p2_lkid : this is id for To

p3_lkid : this is id for Related to, see screenshot below on how to get that Id

p24 : this is id for Additional To

p4 : this is id for CC, see have 2 email address here, one from a merge field and one is static

template_id : this is field id to determine which email template to be auto load, you can get the template Id from template URL, example: https://na3.salesforce.com/00X50000001FypB?setupid=CommunicationTemplatesEmail
Now, how to get the id? If you are using Google Chrome, right click edit page in Salesforce and select "Inspect Element", see screenshot below:





See that id "p24" is related to Additional To, using the same way you can get all field id to use :)

Note:

This custom button need to add into Opportunity page layout, button will be in Opportunity detail, not in the Activity History
You can implement the same for other object: Case, Contact, custom object and etc.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: