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
dietcoladietcola 

custom button for email template: sending to a non-related Contact

Hello, all-

I have what I fear to be a long-shot question:

I currently have a custom button on a custom object that executes an email template.  This code works; it sends the email template to a Contact that is directly related to this object via a look-up field:

location.replace('/email/author/emailauthor.jsp?retURL=/{!Custom_Object__c.Id}&p3_lkid={!Custom_Object__c.Id}&rtype=003&p2_lkid={!Custom_Object__c.VolunteerId__c }&template_id=00X50000001JKO1&p26=myemail@domain.org&p5=');

My problem is that I need a similar button that will send the same email template to a Contact in my system that is not directly related to this object via a look-up field.

I have both a cross-formula field storing my desired Contact's full name and a cross-formula field storing my desired Contact's email address.  I tried putting each of those fields in my code, replacing the {!Custom_Object__c.VolunteerId__c } part, but no dice.  (It looks like only ID fields work here--not custom fields.)

Is there another way?

Either 1) adding this other Contact in the "To" field, so that it would have its own button, or 2) adding this other Contact to the "CC" field, appending this other Contact to my existing button, would be equally fantastic.  I have no preference.


Many thanks in advance!

Best Answer chosen by Admin (Salesforce Developers) 
werewolfwerewolf

Or p24.  You can't put a non-Contact into the To field but you can put a non-Contact email address into the Additional To field.

All Answers

chriseustacechriseustace

You have to make sure you have an email field on the contact populated, and use related email - Check this for an example:

 

http://www.eustaceconsulting.com/blog/how-to-auto-populate-an-email-with-an-email-template-from-a-button/

dietcoladietcola

I'm not sure this is what I need.  The link you provided shows how to add a button to a Contact or Lead record--in those cases, who the email will be sent to is obvious to Salesforce, and there's no need to specify a "To" name or email address in the button code at all.  I'm asking about how to do this for a custom object, where it is necessary to specify in the code who the email is being sent to.

 

Thank you for the reply.  Other thoughts?

werewolfwerewolf

p24 for additional To:.  p4 for CC.  Firebug is your friend -- you can find these things by using the element inspector of Firebug and mousing over the fields you want to prefill.

dietcoladietcola

Thanks, werewolf, but that's not the part I'm having trouble with.  I've been messing with it more since I posted, so hopefully I can articulate my problem better:

 

I have a custom object, and on that object, I have a cross-object formula field that contains a person's name.  I tried adding this:

 

&p4={!Custom_Object__c.Persons_Name__c}

 

to my custom button's code, and the person's name indeed populates into my email template's "CC" field.  The problem (I think) is that Salesforce will only allow internal users to be CCed on email templates; it doesn't allow random contacts to be CCed.

 

I also have a cross-object formula field that contain's said person's email address, so I tried this instead:

&p2={!Custom_Object__c.Persons_Email__c}

 

and still no dice.  The "To:" field doesn't populate at all.

werewolfwerewolf

Well, you do have to fill it with an email address, so perhaps

 

&p4={!Custom_Object__c.Persons_Email__c}

 

(you had p2 in there)

werewolfwerewolf

Or p24.  You can't put a non-Contact into the To field but you can put a non-Contact email address into the Additional To field.

This was selected as the best answer
dietcoladietcola

Beautiful; p24 solved all my ills.  Thanks very much!