function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Abdul RazzaqAbdul Razzaq 

Custom Email Button on Lead page.

Code:-

location.replace('/email/author/emailauthor.jsp?retURL=/{!Lead.Id}&p3_lkid={!Lead.Email}&rtype=00Q&p2_lkid={!Lead.Id}&template_id=00XA0000000RfyB&p5=&save=1');

Error:-

The value of the "p3_lkid" parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information. 
Best Answer chosen by Abdul Razzaq
Abdul RazzaqAbdul Razzaq
Use the both javascript and apex class for easy way.. 

All Answers

Here-n-nowHere-n-now
p3_lkid can only take an ID as input.  If you pass in the lead email (merge field {!Lead.Email}), it's considered invalid input.
Abdul RazzaqAbdul Razzaq

Hi,

Even though I changed my code I get the same error.

location.replace('/email/author/emailauthor.jsp?retURL=/{!Lead.Id}&p3_lkid={!Lead.Id}&rtype=00Q&p2_lkid={!Lead.Email}&template_id=00XA0000000RfyB&p5=&save=1');

Here-n-nowHere-n-now
Same goes for p2_lkid.  Can't have non-id stuff in there.  Also I think p2_lkid is only for Lead and Contact, and p3_lkid is for other objects, similar to Task's WhoId and WhatId.
Abdul RazzaqAbdul Razzaq
So, you mean to say I wont need p3_lkid for Lead object. Is it?
Abdul RazzaqAbdul Razzaq
Use the both javascript and apex class for easy way.. 
This was selected as the best answer
nonprofit adminnonprofit admin
Hi,

Did you ever get this to work? I have it working nicely on the Contact Object and used the same logic for Lead but my merge fields on the template do not populate (with the exception of the First Name). I am still trying to get it to work on the Lead object. Any more insight?

Thanks so much ...
nonprofit adminnonprofit admin
Here's the working link:

(your na location)/email/author/emailauthor.jsp?p2_lkid={!Lead.Id}&rtype=00Q&
&p3_1kid={!Lead.Id}&template_id=(your specific template id)