3

I need to be able to load and render an email template in a visualforce page. What are my options here?

I understand that loading it is as simple as querying the EmailTemplate table. Now how do I render it in my visualforce page so the letterhead appears, etc?

1

2 Answers 2

4

Your somewhat limited in your ability to render the template with any of the built-in Visualforce components, for one there isn't a way to get 'Merge Fields' to render the accompanied values.

With that in mind, I think the safest way to do it would be to create a frame and render the EmailTemplate.HtmlValue (EmailTemplate) as un-escaped HTML once you have queried the template in your VF Controller (probably would query the template by name)

1
  • Hey thanks! Is there anything special I need to do about the <![CDATA[]]> markups contained in EmailTemplate.HTMLValue?
    – Jan Julian
    Dec 26, 2012 at 21:27
0

you can get Merge Fields from email Template..

 
for(EmailTemplate templ : selectedTemplateList) 
{  

Organization org = [SELECT id, Name FROM Organization]; Id orgId = org.Id; String Name = org.Name;

      templ.Body = templ.Body.replace('{!Organization.Name}',org.Name); 

            this.emailTemp.body = templ.Body.replace('\n','<br>') ;
            this.emailTemp.htmlValue =  templ.Body.replace('\n','<br>') ;
            this.emailBody = templ.Body; 
            this.emailSubject = templ.Subject; 
break;  

}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .