function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
pmozzpmozz 

Unknown property 'core.email.template.EmailTemplateComponentController.Lead' in VF email templates

I am creating a VF email template on Lead that is meant to render a PDF as an attachment, but keep getting the above error.  Any ideas would be appreciated!  My code is shown below:

 

<messaging:emailTemplate subject="Provider Application" recipientType="Lead" relatedToType="Lead">

    <messaging:plainTextEmailBody >
        Dear {!recipient.name},

 

                                   PLAIN TEXT BODY

 

   </messaging:plainTextEmailBody>
         <messaging:attachment renderAs="pdf" filename="{!relatedTo.Company}">
        <apex:stylesheet value="{!URLFOR($Resource.pdfresource, 'styles.css')}"/>
          <apex:image url="{!$Resource.Logo}"/>

 

                                     FIELDS TO BE DISPLAYED

 

        </apex:panelGrid>
        </body>
        </html>
    </messaging:attachment>
</messaging:emailTemplate>

pmozz01pmozz01

Well, I think that I figured out the first problem on save since I was calling fields like this:

 

{!Lead.Company}, but when I changed them to {!RelatedTo.Company}, I no longer received the error.  However, when the PDF renders as part of the email and attaches to the email,all of the fields I referred to with the {!RelatedTo.XXX} are blank.  What am I doing wrong here?

 

Please help - thanks!!!!

joshmojoshmo

I was left with blank fields whenever I selected the email template before selecting the Contact to whom I was sending the email.

Are you manually sending the email with attached PDF from the lead itself? Or is this an automated email?

pmozz01pmozz01
I am sending an automated email that triggers on workflow.  I do believe that to use an email template manually, you have to be on the lead or contact, select "send email" and then select the template for it to properly populate.