<messaging:emailTemplate subject="Test to Pass Value" recipientType="Contact" relatedToType="Account">
<messaging:HTMLEmailBody >
account: {!relatedTo.Name}
<c:EmailComp ToID="{!relatedTo.Id}"/>
</messaging:HTMLEmailBody>
</messaging:emailTemplate>HTMLEmailBody>
</messaging:emailTemplate>
VisualForce Component:
<apex:component controller="EmailController" access="global">
<apex:attribute name="ToID" type="ID" description="the account ID" assignTo="{!accountID}"/>
<h1>{!account.Name}</h1>
<apex:dataTable value="{!EmailContentAddOns}" var="Add_Ons">var="addOns">
<apex:column >headerValue="Add On">
{!addOns}
<apex</apex:facet name="header">Account Name<column>
</apex:facet>dataTable>
</apex:component>
Apex Controller:
public class EmailController {
public ID accountID{!Add_Ons.Add_ons__cset; get;}
public Account account {
</apex:column>get {
</apex if (accountId != null && account == null) {
account = [
SELECT Name
FROM Account
WHERE Id = :dataTable>accountID
< ];
}
/apex:component>/ Always return the account
Apex Controller:
public class EmailController { return account;
}
public List<System__c> AddOns; set;
}
public ID accountID;
public IDList<System__c> getaccountID()addOns {
return accountID; } get {
public void setaccountID if (IDthis.account s){!= null
accountID //&& this.account.Add_Ons__c != s;null
getEmailContent && this.addOns == null) {
this.addOns = new List<System__c>();
}
String accountString = '' + this.account;
public void generateEmailContent() {
AddOns = [select Id, Add_Ons__c List<System__c> allAddOns = Database.query('Select Add_ons__c From System__csystem__c whereWhere account__caccount__r.Name = :accountID' ];+ accountString);
} addOns = allAddOns;
public List<System__c> getEmailContent() {
}
return AddOns;addOns;
}
set;
}
}