+ Start a Discussion
john.krjohn.kr 

Hi !How to access the class in visualforce Email Template

How to access the class and methods in visualforce Email Template,Is it possible

Vinit_KumarVinit_Kumar

John,

 

You can create a Visualforce component and can use in your visualforce email template.

 

For more info and sample,please go through below link :

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_email_templates_with_apex.htm

SFDC_LearnerSFDC_Learner

Component:

 

<apex:component controller="myAccountsDisplay" access="global">
<apex:outputtext value="Welcome to my First Component" style="font-size:20px;color:blue;"></apex:outputtext> <br/><br/>

<apex:datatable value="{!lstAcc}" var="a">
<apex:column headerValue="Name" value="{!a.name}"/>
</apex:datatable>

</apex:component>

 

 

class:

 

public with sharing class myAccountsDisplay {

public List<Account> lstAcc{get;set;}
public myAccountsDisplay(){
lstAcc = [select id,name from Account];
}
}

 

 

 

VF Template:

 

<messaging:emailTemplate subject="test" recipientType="User" >
<messaging:HTMLEmailBody >
<c:testingComponent />
</messaging:HTMLEmailBody>
</messaging:emailTemplate>