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
BosaBosa 

Quick-Email button: using it within an Opportunity

Relating to the article titled The Quick Email Button in the Service & Support Blog of Successforce, I had the following query:

I'm trying to co-opt what Marco Casalaina did for a Case to create a link for an Opportunity.  I'm calling it "quick close email" which, as planned, will allow a rep to pull up our closing email template with one click from the Opportunity page. The syntax I am using follows:

Code:
location.replace('/email/author/emailauthor.jsp—retURL=/{!Opportunity.Id}&p3_lkid={!Opportunity.Id}&rtype=003&p2_lkid={!ContactId}&template_id=<your template here>');

Where "your template here" is the 15-character ID for the email template I would like to use.

Unfortunately, there's something wrong with the command -- it returns an "Unable to Access Page" message when launched from the opportunity. Doubly unfortunately, I know nothing about javascripts, so I can't troubleshoot this on my own. Any clues for me? Thx!
werewolfwerewolf
Well, let's see.

Your merge field is wrong, for one.  Opportunity has no {!ContactId}, nor does it have the properly formatted version, {!Contact.Id} -- opportunity has a
separate Contact Roles table.  If you have made a custom field that is a lookup to Contact then you could use that, but by default opportunity has no
direct Contact field.

Did you in fact put a template ID in the <your template ID here> or are you actually using that verbatim?  If your URL really says <your template ID here>
then that won't work, you have to put a real template ID there per the instructions on the blog.
BosaBosa
Looks like I'll have to create a custom field that is a lookup to Contact.  Or perhaps I could just use the Contact Roles (primary contact) in the same way.  I'll toy with that.  My problem is understanding the syntax, not understanding the concepts.  And yes, I did actually use the 15-digit template ID, not the <your template ID here> text.

Thanks, Werewolf. 
werewolfwerewolf
If you want to use Contact Roles you'll have to query on the primary contact and plug it in rather than using the merge fields -- at least, I don't think there's a merge field for the primary contact of an opportunity.
RDSUPPORTRDSUPPORT
Hi Werewolf,

I'm trying to use also the Quick Email Button.
I have implemented it and it works just fine,
the only thing I would like to modify is the "To" recipient and I can't seem to find how to do it.
Do you have any clue?

Thank you in advance for your help,
Cédric
BosaBosa
Cedric,

Would you be so kind as to copy the text of your javascript into the discussion here?  I don't understand the syntax well enough to make it work, as easy as it should be.  It sounds like your attempt worked... I'm a newbie, and would appreciate the help.  Thanks!
christeechristee
Hello Werewolf,

I'm trying to do the same thing within a Lead... here is my javascript:

location.replace('/email/author/emailauthor.jsp?retURL=/{!Lead.Id}&p3_lkid={!Lead.Id}&rtype=003&p2_lkid={!Lead.ContactId}&template_id=<00X40000000xczW>&p5=');

Since Leads don't have a contact ID, I'm not sure what should go there instead... Can you help me please?

Christy
werewolfwerewolf
For leads, you want to emulate what the Send An Email button does when you press it from a lead.  That means get rid of the p3 parameters and only use the p2_lkid, and set it ti {!Lead.Id}.  And the rtype will be 00Q.
christeechristee
Thanks for your response... Did I intrepret you correctly (sorry, I don't really know Java) here:

location.replace('/email/author/emailauthor.jsp?retURL=/{!Lead.Id}&rtype=00Q&p2_lkid={!Lead.Id}&template_id=<00X40000000xczW>&p5=');

It still isn't working... =(
werewolfwerewolf
Well, for one, you have to take the < and > off of the template ID.
christeechristee
Werewolf, you are WONDERFUL - thank you!!!
christeechristee
Hello Werewolf,

I'm trying do to the same thing, but as a Detail Page Link instead, but it isn't working... can you help again, please?

location.replace('/email/author/emailauthor.jsp?retURL=/{!Contact.Id}&rtype=00Q&p2_lkid={!Contact.Id}&template_id=00X40000000xd0Y&p5=');

Christy
werewolfwerewolf
As a detail page link you have to either get rid of the location.replace and just put the URL there (it may have to be fully qualified with an http:// and so on), or leave the location.replace and put a javascript: in front of it.  What you were doing before was JavaScript – what you're doing now is a straight-up HTML link.  That's the difference.
christeechristee
It didn't work as a URL so I tried to make it a button using the same javascript as above, but that didn't work either.
arvorisarvoris
Is it possible to create a Quick-Email button to email the owner of a Contact?  I'd like for the users to be able to email the owner of a contact easily to request permissions to the contact, etc.
werewolfwerewolf
You can, but not by URL-hacking the send an email page.  You'd have to use the sendEmail API verb instead.
arvorisarvoris
:smileysad:Here's the time when I have to admit to having no clue how to do this.  Can you possibly direct me to a help page or article?  Thank you very much for your response.
werewolfwerewolf
The sendEmail example in this doc would be a good start:

http://www.salesforce.com/us/developer/docs/ajax/Content/sforce_api_ajax_more_samples.htm?Highlight=sendEmail
arvorisarvoris
Thank you!  I'll check it out immediately.
EmsEms

Hi all,

Thanks for all the contributions to this thread - in leiu of a user's guide on url parameters it is a great help!

 

I am trying to do basically the same thing as everyone else here, with one caveat I can't compensate for.

 

I want to send the email to an address that is stored in a custom field on a record (I know, it should be a contact lookup but it's not for a very good reason which I won't get into here.)

 

So I have set up my url as follows:

/email/author/EmailAuthor?p2_lkid={!Marketing_Request__c.RequestorEmail}&rtype=003&retURL=%{!Marketing_Request__c.Id}&templateId=00X4000000125P3

And I think the issues lies in the p2_lkid={!Marketing_Request__c.RequestorEmial} as this is NOT a contact ID.
 
Is there a parameter I can set that is the toaddress, not a contact id from which Salesforce gets the email address?
 
Thanks, any info would be great.
 
Emily
 
BTW Is there a guide to parameters anywhere??? I can't find one!


Message Edited by Ems on 09-09-2008 02:18 PM
Ron WildRon Wild

Posting parameters to EmailAuthor is not supported by Salesforce, so no, there is no documentation on the parameters it will accept.  You'll have to deduce this by inspecting the page and pages that call it using tools like Web Developer for Firefox that show the form field names.  Some have posted their findings here and and on blogs.  Try Googling EmailAuthor.

 

On a closely related topic, I found that Visualforce email templates with visualforce attachments require an additional parameter:

 

new_template=1

 

So a full custom link might look like:

 

/_ui/core/email/author/EmailAuthor?p3_lkid={!Opportunity.Id}&template_id=00X700000015lI1&cancelURL=/{!Opportunity.Id}&retURL=/{!Opportunity.Id}&new_template=1

 

 

Without "new_template" the email template will appear, but not the visualforce attachments.

 

Hope that helps someone out there.

 

 

DrawloopSupportDrawloopSupport
I'm trying to create a visualforce page to replace the emailauthor page. Any way to use the standard button functionality in this visualforce page (i.e. send, select template, attach file, etc)?
werewolfwerewolf

Good luck with that.  You're going to have a very hard time getting it to resolve an email template and make it editable before you send it out. 

 

To your question, no, you'll have to write your own buttons (although while you're at it maybe you can make the attachment button inherit attachments from the parent object, which it currently doesn't do).

metastorm-lizmetastorm-liz

Hi all-

 

I found http://blogs.salesforce.com/support/2008/07/the-quick-email.html very helpful, but now am trying to take it a little further... I have the below for sending an email from a Lead record...

 

location.replace('/_ui/core/email/author/EmailAuthor?retURL=/{!Lead.Id}&rtype=00Q&template_id=00XS0000000QLzT&p2_lkid={!Lead.Id}&p5=')

 

This works great, but I don't want the 'To' entry to populate. The problem is that if I remove 'p2_lkd={!Lead.Id}', then the Lead merge fields in my email template do not populate.  Is there a way the merge fields can pull from the Lead record, but not poplulate the 'To'.  Ultimately I would like a button to email the Lead information to someone else.

 

Thanks in advance...

 

FYI- Chirag post here is also helpful if have not seen - http://community.salesforce.com/sforce/board/message?board.id=scontrols&message.id=1063

Fra08Fra08

hello, I finally found the solution! :robothappy:

you have to add  the parameter "p3_lkid= {!Lead.Id}"

 

this is my button:

 

 

location.replace('/email/author/emailauthor.jsp?p3_lkid={!Case_Study__c.Id}&retURL
=/{!Case_Study__c.Id}&rtype=00Q&template_id=00X20000001L1H7&new_template=true'

 

 

 

dietcoladietcola

Thank you, Fra08!  Copying that code solved my Lead email template/custom button woes.

jbardetjbardet

is there any way to dynamically select the template using a few nested IF statements?

 

undercontructiondevundercontructiondev

Hi,

 

I hope this thread is not dead.  I just created a Quick Email button using Werewolf's code.  I want the email to go to the record/case creator (Created By).  Based on the code I have, it goes to the case owner.  Can someone help me identify what needs to change in the code below.  Admittedly not a Java Girl.  Other than this, the button works perfectly...just going to the wrong person.  Here is my button:

 

location.replace('/email/author/emailauthor.jsp?retURL=/{!Case.Id}&p3_lkid={!Case.Id}&rtype=003&p2_lkid={!Case.ContactId}&template_id=00X40000001T2B0&p5=&save=1')

 

Thanks.