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
Amit_Amit_ 

Auto Populate CC field while sending Emails

Hi I have a requirement where on contact object I will have to create new Custom button and on click of that button it will send out mail. that is simple but the problem is I have to auto populate the Addition to and CC filed with some email Id like sample@g.com , sample2@g.com like that based on the particular email template choosen.

I dont have any idea how to achieve it any help is highly appriciate.

 

Thanks and Regards

Sonam_SFDCSonam_SFDC

Hi Amit,

 

I would suggest you to design a custom email sending mechanism using SendEmail() such that you can then autoplpulate the email  fields you have mentioned.

- Design a custom button

- Design a VF page that lets you select the template

- Write SendEmail() code such that you are able to use the populate the email fields depending on the name of template.

 

Reference:

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_sendemail.htm

Boom B OpFocusBoom B OpFocus

Hi Amit,

 

Please try this in Contacts Custom Button.  (Select Display Type = "Detail Page Button" and Behavior = "Execute JavaScript".)

 

location.replace('/email/author/emailauthor.jsp?retURL=/{!Contact.Id}&rtype=003&p2_lkid={!Contact.Id}&template_id=00Xi00000012xit&p24=sample@g.com&p4=sample2@g.com&p5=');

 

Below is a list of parameters definitions:

 

template_id = id of email template you want to pre-populate
email_type=visualforce (if the template that you're using is a VF email template)
new_template=1   = required if you're using a VF email template that contains an attachment
p2_lkid = id of the record for the To address (a Contact, Lead, or User Id)
rttype = the id prefix for the type of the To address (e.g., if p2_lkid refers to a Contact, use rttype=003)

p3_lkid = id of the record for the Related To (i.e., What) record (e.g., an Account or Opportunity)

p4 = CC address
p5 =  BCC address
p6 = Email subject
p7 = Email body

p24 = Additional To
p26 = From address
doc_id = the id of a Document or QuoteDocument to become an email attachment

retURL = URL to return to after the email is sent
cancelURL = URL to return to if the user clicks Cancel
Amit_Amit_

Hi Boom,
Thanks for the reply, but i have one doubt with this apporach I am able to achieve the solution to my probelm. but the issue is once the send email window is opened and the values are auto populated and then If i go and change the template, still the Additional to and CC values are reflecting. How will I remove the auto populated filed values if the Template is changed.

Thnaks & Regards,

Boom B OpFocusBoom B OpFocus
Hi Amit,

This approach is only a quick solution for a custom button with pre-populated values, anything after that has to be manually updated (like clear Additional to and CC values). If you want those two values to automatically clear out after you changed the template, I think this has to be a Visualforce page.

Thank you