+ Start a Discussion
nagachandra knnagachandra kn 

passing paramters from visualforce emailtemplate to vf component not working


I have created a visualforce email template on which fetches the lead details and we have one custom object called leadinfo__c from this one as well. Now the problem is the lead id from template is not getting passed to the vf component. could you please help?

Vf template
<messaging:emailTemplate subject="test" recipientType="Lead" relatedToType="Lead">
<messaging:plainTextEmailBody >

<c:getLeadInfo LeadId="{!RelatedTo.Id}"/>


vf component
<apex:component controller="LeadInfocon" access="global">
    <apex:attribute name="LeadId" 
                    type="id" required="required" assignTo="{!leadVarId}" description="To get the lead id from template"/>
    <apex:outputText value="{!leadVarId}"></apex:outputText>
    Hi {!leadinfo.lead__r.name}, 
    You were recently on realtor.com and saw a property that you were looking to get some information on {!leadinfo.Street_Address__c} ADDRESS, {!leadinfo.City__c} .it is the four plex property. I have a team of agents here in our Fresno office and any one of them would be happy to assist you and answer any questions may have along the journey to your new home. Feel free to give me a call so that I can connect you to them, my direct line is 559-517-3436. 
    Thanks {!leadinfo.lead__r.name}
    Have a good day.

controller for compoent
public with sharing class LeadInfocon {
    public LeadInfo__c leadinfo ;
    public LeadInfo__c getleadinfo(){
        if(leadVarId == null)
            leadinfo = [Select ID, Street_Address__c, City__c,Lead__r.name, CreatedDate from LeadInfo__c where Lead__c = :leadVarId order by CreatedDate desc limit 1];
        //system.debug('Lead name::'+leadinfo.lead__r.name);
        return leadinfo;
    public void setleadinfo(){
    public id leadVarId {
    public lead ld {get;set;}
    public LeadInfocon(){

What i am doing wrong? Please help.

NagendraNagendra (Salesforce Developers) 
Hi Chandra,

May I suggest you please check with below link from the community which might help you to accelerate further. Please let us know if this helps.