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
RiPaulRiPaul 

How To: Have a custom Task button pass parameter data to an e-mail obj, or any other object?

Hello,

 

I have what I think should be a basic question, but I can't seem to readily discover the best route to meet my requirementd.    As background, we work primarily out of the Task object managing prospect and customer follow up communications.   

 

I want to start extending the stock Task object to perform common actions more directly.   For example, I'd like to have a new button (I know how to do this and add to view, etc) called "Final Follow Up".   When this button is pushed, the event should pass the lead or contact name info associated with the Task to a new e-mail obj with my  canned final follow up e-mail template applied.   Here's what my final e-mail template looks like:

 

Hi {!Contact.FirstName},

Some generic final message body. 


Kind regards,
{!User.FirstName}

 

So, the event would invoke a new SF e-mail editor (or just send directly which would be even better) with the communications template of choice applied (in this case final follow up) and the Contact.FirstName would be set by data passed by the Task event (via the URL or something).   I'm not sure if I should plow down the JavaScript or Apex route and therefore, any advice one of you could extend on how to best get started would be tremendously helpful.   Thanks in advance!!

 

-Paul

Best Answer chosen by Admin (Salesforce Developers) 
RiPaulRiPaul

Thanks for the input, Srinivas!   I'll check out your suggestions.   I've used those e-mail features from a .NET app I've built that integrates our license generator with SF.   I've had little trouble with the Force.com API from Visual Studio (via Web service), but it's a whole different animal trying to use the SF DE.   Anyway, let me see where I can get with your nice suggestions and then I'll get back to you.  

 

In the meantime, thanks again for taking the time to reply to my post.

 

 

-Paul

All Answers

sforce2009sforce2009

You can do it either using JS or apex.

If you just want to send an email on click of button then use a apex web service and call it from Onclick javascript of the button like sfdc.apex.execute

 

http://www.salesforce.com/us/developer/docs/cookbook/Content/messaging_outbound_vf_email.htm

 

Or if you want to show a custom message like "Email has been sent " use a VF page and vf's email template functionality

 

If you are using class then use SingleEmailMessage, You can select the email template and replace the merge fields accordingly.

 

If you feel, the above is confused for you let me know. I will give you some guidance with code.

 

Thanks

RiPaulRiPaul

Thanks for the input, Srinivas!   I'll check out your suggestions.   I've used those e-mail features from a .NET app I've built that integrates our license generator with SF.   I've had little trouble with the Force.com API from Visual Studio (via Web service), but it's a whole different animal trying to use the SF DE.   Anyway, let me see where I can get with your nice suggestions and then I'll get back to you.  

 

In the meantime, thanks again for taking the time to reply to my post.

 

 

-Paul

This was selected as the best answer
RiPaulRiPaul

Thanks again for the help.  Your suggestion along with what was found here met the requirement: 

 

    http://sfdc.arrowpointe.com/2009/01/08/invoke-apex-from-a-custom-button-using-a-visualforce-page/