You need to sign in to do that
Don't have an account?

Creating a button to send template email to contact
Hi - hopefully a simple question.
I'm trying to create a custom button to send a template email to the lead.
I've found some relevant board posts but they all seem for more complicated uses - I'm simply looking for a button that would mimic the following:
Activity:Send An Email
Select Template
[template id]
Send
Does that make sense? I'm familiar with how to create buttons, I just can't figure out the syntax.
Well, you can create a custom button and put the source as OnClickJS!
You just need to redirect the user to the send mail page with the template loaded-
https://test.salesforce.com/_ui/core/email/author/EmailAuthor?p2_lkid=003S000000XXXXX&rtype=003&p3_lkid=500S000000XXXXX&p26=test@test.com&template_id=00X700000015WDiEAM&retURL=%2F500S000000XXXXX
As you can see, you need the template ID to pre-load it on the page and you can pass additional parameters too if you want to in the URL itself!
In case, you want to send the mail automatically, then you need to write some apex code in the backend and execute that in an S-Control/VF page which will be attached to this custom button. You can refer to the apex docs for the syntax of how to send an email through apex code.
Cool_D
Question:
I am trying to figure out how to use your example. Can you break down what is included in your URL?
Also is there a SF document that explains this?
For example: https://test.salesforce.com/_ui/core/email/author/EmailAuthor?p2_lkid=003S000000XXXXX&rtype=003&p3_lkid=500S000000XXXXX&p26=test@test.com&template_id=00X700000015WDiEAM&retURL=%2F500S000000XXXXX
how do i know what the different parameters are, and which other ones can i use?
What is p2_lkid=003S000000XXXXX
What is &rtype=003
what is &p3_lkid=500S000000XXXXX
what is &p26=test@test.com
what is template_id=00X700000015WDiEAM - this is the email template id i think.
Check this link-
Link
Cool_D
Here is a custom URL hack that I just did and it works.
Base URL: https://na6.salesforce.com/_ui/core/email/author/EmailAuthor?
p2_lkid={object ID} = Who we are sending it to
&rtype=003 = Not sure what this is
&p3_lkid={object ID} = What we are relating this to
&template_id=00X80000001Ehde = put your template ID here
&save=1
&saveURL=%2F{object ID}
Replace all the red stuff with your variables. I think you pretty much have to hardcode the template ID, but no biggie.
Set the button behavior to: Display in existing window without sidebar or header
and the Content Source to URL
Add it to your page layout and voila! Magic button that sends out the email template you want, and logs the activity.
I can't, however, seem to make this set the Task type to 'Email' But this was pretty easy. Give it a try!
Question - What if i dont want to use an object ID for teh 'Who we are sending to' but I want to specify the to address as interalteam@xyzcompany.
I've used this button technique to send emails but the user has to select the to from a a dummy account. I'd rather not do that if I can simpy hard type it.
Found the answer: I used the p24 value and it worked fine, add the =save1 at the end of the url and the user never has to even see the email.
x = John Smith
x_lkid = 0036000001HC
The x will fill in the visible text in the look up field. The x_lkid will pass the record ID so that SFDC can create the correct relationship.
Let me know if this makes sense.
Thanks for your answers.
I dropped the _lkid and just used the p24= .
So for multiple users use comma with no space to separate addresses?
Thaanks again.