You need to sign in to do that
Don't have an account?

Send email page with template in Visualforce
I would like to create a similar page to the standard one for sending emails in Visualforce. The idea is to be able to pre-propulate the email page with the template defined for Solution and capture the Send action to change Case status to "Solution provided to customer". I don't know how to read the template and show it with the merge fields replaced by their value, is there a standard way to do this?
you would have to begin by building your final template in Visualforce, rather than in a template, let's call this /apex/emailTemplate, in the page attribute specify the output format as html, or pdf, this page takes an id paramater and fills in the expressions (perhaps a standard controller here)
next, construct another page that will fetch the first page(/apex/emailTemplate) with the case ID, then performs (in apex controller) page.getContent();
here is a snippet , notice we create a page, just to get it's body as a string, it never shows in the browser.
the body can be send in an email, the fields will be filled in by the Visualforce page generator ( getContent() ), pretty cool feature if you ask me
// Pass in the endpoint to be used using the string url
PageReference pageRef = new PageReference( getVisualforcePageName() +'?id=' + record_id );
system.assert(pageRef != null);
// run the requested page thru the visualforce page generator now
pageBody = pageRef.getContent();
system.assert(pageBody != null && pageBody != '');
return pageBody;
now you can use that content with the email services of apex, to send the email, and finaly change the status.
you lose the ability to tack on comments or change the template by the end user, but you coudl add some standard note fields on the case and get something like this back again.
pageBody = pageRef.getContent().toString()
Ambili
Message Edited by arasu on 08-11-2008 10:04 AM