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, AdditionalTo, 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.
相关文章推荐
- How to Send an Email Using UTL_SMTP with Authenticated Mail Server
- Using RestTemplate, how to send the request to a proxy first so I can use my junits with JMeter?
- How to Send an Email Using UTL_SMTP with Authenticated Mail Server
- How to Send an Email Using UTL_SMTP with Authenticated Mail Server
- How to Send an HTTP Header With Every Request With Spring RestTemplate
- How to Send an Email Using UTL_SMTP with Authenticated Mail Server. (文档 ID 885522.1)
- How to Send an Email Using UTL_SMTP with Authenticated Mail Server
- Cognos How to set the default email sender to a specific value
- How to send an email from oracle workflow process using an AdHocRole?
- how to send email
- 创造应用英语环境学英语-how to send email
- prjSendMailInUniversity - How to send email using VB & Winsock - 邮件发送接收程序 - VB6 + Winsock
- How To Default To Search Companion With Windows Desktop Search 3
- Custom checkout cart – How to send email after successful checkout
- How to use LabVIEW to send Email?
- How to send mail using any email account through Foxmail ? - Foxmail 6 漏洞,如何通过 Foxmail 用任意邮件账号发送邮件?
- How to send email via vbs using cdo
- Custom checkout cart – How to send email after successful checkout
- iOS Programming 101: How To Send Email in Your iPhone App
- Android: How to share with Email (如何用邮件分享信息)