But, can we make user even more productive? When user hit Send an Email button, template will be auto select, and recipients 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.
I found out the parameter is %26 for the FROM ADDRESS
ReplyDelete