Sending Email using Email Author in custom button
The email author URL should look like below. Out of all the parameters I would always use "p3_lkid" and "retURL". Rest of the parameters are optional. Let's break this down:
_ui/core/email/author/EmailAuthor?p3_lkid=001E000000CVCF7&retURL=%2F001E000000CVCF7&p2_lkid=003180000066S1e&[email protected]&[email protected];[email protected]&p6=Hello World&p23=Nice to meet you&[email protected]&template_id=
p3_lkid = "Related To" Id. Based on the Id, Salesforce will automatically select the object and record. This Id will be used to populate the merge field, if you are also using a template.
retURL = Return URL if cancel is pressed. Followed by %2F.
p2_lkid = Contact Id. Use to populate "To" field. It automatically fetches the email of this contact to send email. Also, populates the contact merge fields, if used.
p4 = CC
p5 = BCC. I passed two emails separated by semicolons to keep two different people in the loop. Same goes with CC field.
p6 = Subject of this email.
p23 = Email body.
p24 = Additional emails.
template_id = Id of template you are going to use. This template should contain merge fields of the same object as p3_lkid. No need to pass p6 and p23, if the template already handles them.
Now, coming to your case. There is no need to keep the behavior as javascript. URL behavior could have also met your requirement. Hence, I am modifying your code considering the behavior as URL.
/_ui/core/email/author/EmailAuthor?retURL=%2F{!Opportunity.Id}&[email protected];[email protected]&template_id=00Xj0000000J8sI&p3_lkid={!Opportunity.Id}&[email protected]
Removed P3 - If you're using p3_lkid, then no use to do this.
Removed p26 - NOT sure what you trying to achieve here.
Used semi-colons between emails.
NO need to use location.replace and inverted commas. Simply copy paste the url with behavior as "URL".
Also, you should use merge field for "p24" by creating formula field for that.
To add more parameters, please see the structure above.
PS:- It would better if you query the template based on its developer name. However, then you will have to execute the button as javascript.
Also you can add "&new_template=1" if you want attachments from email templates to show up.