+ Start a Discussion

Populating merge fields from the EmailTemplate object

So I'll preface this by saying that I realize that what I'm trying to do is twist existing functionality for my own purpose and there may not be a way to do this.  But hope springs eternal, so...


What I want to do is create a Visualforce page that pulls an email template from the EmailTemplate object and populates any merge fields in the body of that template.  The reason I need this is because I need to send an email about a Contact record to someone other than that contact, namely a Parole Officer.  So I have a Contact record with a PO field that is a lookup to the Contact table, and the email will be sent to the email address of that PO.  I put together a page to do this, but when I output the email template body to an inputTextArea, all of the merge fields are written out explicitly (i.e. {!Contact.FirstName} {!Contact.LastName}, NYSID #{!Contact.NYSID__c}).


Does anyone have any ideas on how I might be able to accomplish this?  If I can't find a solution, I'll just create Visualforce email templates, but since there are a lot of templates required and they change frequently, it would be nice to let certain end users create them as Email Templates instead of having to code it in Visualforce myself.