I am creating an email template which will be sent to individual contacts, the template needs to list rows from a related object. I have created the relevant component and class which I believe would have achieved this however I have come across some issues:
relatedTo Contact details are not loaded
I get the following error when trying to save the email template when using my Contact fields
Error: Invalid field Contact for SObject Account
The line in question is {!relatedTo.Contact.Name}
Email Template:
<messaging:emailTemplate subject="My email subject" recipientType="Contact" relatedToType="Account">
<messaging:htmlEmailBody >
<p><apex:outputText value="{!TODAY()}" /></p>
<p>REF: <apex:outputText value="{!relatedTo.Name}" /></p>
<p>Dear {!relatedTo.Contact.Name},</p>
<c:ORCLetter_Component acctId="{!relatedTo.Id}"/>
</messaging:htmlEmailBody>
</messaging:emailTemplate>