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

Help! need custom 'send email' button which can lookup leads from custom objects

hi all, this is my first post, made in desperation after searching to try and find this solution already discussed but no luck so far.


my problem is the restrictions on the behaviour of the inbuilt send email button in only lookingup contacts or person accounts. - I need to use the 'send email' functionality from my custom object (in order to merge the custom object field data into the email template) to send emails to leads as well as accounts, and I don't want to convert these leads at this stage just so that I can send them this email (I intend to automate this email being send to new leads on creation in the future).


I understand that I need to use a custom 'send email' button in replacement of the standard one, and the code for this button should facilitate contacts/person account and leads both being permitted in the recipient lookup.


has anyone built this already and can help me out?



hello, I created an automatic button to send e-mail from the contact (but you can create it where you want):
- customize object
- create new button
- Behaviour: Execute JavaScript
- this is the link:
The important parts are those in red: as you can see you have the parameter p2 who is the e-mail of the customer
and the template.
I hope this help you

Hi Fra08, thanks for your response


I think this is along the right lines of a solution for me - do you think you could help me expand on this please?


I want the button to sit on the page layout of a custom object, and the custom object is in the related list of the lead


so in the test example I've got the object ( and one of the fields within the object ( is a lookup field detailing the lead (


when I use the built in 'send email' button, I get the 'to' field come up blank and the 'related to' fields already populated with the object from which I'm emailing i.e object type (picklist) and reference (lookup)


so, I'd like my custom email button to do exactly as the built in one does, but for it to also populate the 'to' field with the lead that is detailed in the lookup field on the object.


the reason the email needs to be related to the object is that the template merges data from the object, so without being related to it all the merge fields remain blank


any assistance appreciated




I'm having a similar problem (I think). I've created the custom button and now I'm able to send the email, but it isn't carrying over the email field from the previous page. I'm building the custom button on the accounts page and want the email to go to the email address from a custom field on that page when I click the button. Right now the "To" field is coming up blank. Here are some examples of code I have tried:






Any suggestions?


Thanks in advance!




Okay, I'm now one step closer. I somehow have managed to get the email address to show up in the "Additional Email" field with this code:




For some reason I still can't get it to show up in the regular "To" field... Does anyone have an idea of where I went wrong?

Did you ever get the To field to auto-fill?
No, it still shows up in the "Additional To" field.
Is that how you are using it? Does it make any difference in where that activity shows?
Yes, it works and it logs the email as an activity in the account that you send it from. It is just a little confusing for users.

Hi folks!

I'm trying to do the same thing here, send an email on button click by executing javascript.  The issue I have is that im doing it off a custom object (called Application_Project_Line__c), not a standard one as in these examples.  I'm getting an error saying:


Unable to Access Page Invalid parameter value "00520000001Hifc" for parameter "p2_lkid". 


p2_lkid is the ID of a user who is set in a field called Assigned_User so I dont see that is an issue, I have a template set and the return url is set as the original Case ID. FYI my custom object is related to cases.


I think the issue is the type, with it being a custom object I'm not sure what to put in.  This is what I have:




I've taken a07 from the url of the object, was just a random guess really because I tried all the sensible ideas I could think of!


Can anyone else help please, all the examples I can find use standard objects so I dont know where to go with this.






PS, just to get out a couple of the obvious suggestions, in the type I've put in the ID of the Object (ie i've gone to create>objects, selected my object and taken it's ID from the url) and that didnt work.  I've also tried {!$ObjectType.Application_Project_Line__c} but each time I get the same error.

Message Edited by ministe2003 on 03-04-2010 01:49 AM

I had created this button and it was working for several weeks. All of a sudden for some of our users, the alert comes up,


"A problem with the online Javascript for this button or link was encountered.
Object doesn’t support this property or method."



Anyone else having issues with custom e-mail buttons via the method described in this thread???


I have the same Invalid Parameter error--wound up removing the rtype= portion, as I had guessed the same (a09) and once removed, I don't get the error. However, I am still not populating the template, which I originally was at one point, but that had broken something else. Here's what I've got currently:


location.replace('email/author/emailauthor.jsp?retURL=/{!Account_Setup__c.Id}&p3_lkid={!Account_Setup__c.Id}& template_id=00X70000001BDzf&p5=');


Were you ever able to resolve this? Mine is likely more simple--I don't need to populate the additional to field.


i found that the problem was for Internet Explorer users. I had them try the button using firefox and they said it worked just fine. it bothers me though that it wasn't working with some versions of IE (i think they are using 8.0). But on my Mac running VMware, the button worked fine in IE 8.0.  strange.


now I get the problem in IE as well.


Is anyone still able to use the custom email buttons from Internet Explorer?




I was successful with:




Instead of using Javascript, I used a URL as a Detail Page Button.  Should work in any browser as it's just a URL statement.  Event_Contact is my custom object.


Hi all,

I have been doing some more work which required a custom send email button, and I've figured out what my problem was all that time ago (last post on page 1 of this thread).


Because I was trying to send off a custom object (I just knew that was the problem!), that object needs to be set up to allow emails to be sent from it.  To see if your object will allow emails from it, go to /_ui/core/email/author/EmailAuthor and see if your object's name appears in the "Related To" list of object names.  Mine didnt.


To resolve this, open up your custom object and edit it, and make sure "Allow Activities" is checked.


Once I'd done this I was able to use the javascript button to pass through my paramers without a problem.


Hope this helps someone!


What if I wanted the TO: address to be hard typed into the url? We have an email that will allways go the same distribution list and this just makes it a tad faster for the user.


How would this be altered to fit that scenario?




Thank you.


Never Mind, realized that's not going to work after seeing the email that appears. We found a work around.