+ Start a Discussion
John Neilan 2John Neilan 2 

Visualforce Email Template to Related Contacts

I have a VF email template set on the Accounts object that compiles the related Cases to an Account that meet a certain criteria. I would like to send this template to any Contacts related to the Account that are marked as true via a custom checkbox field on the Contact record. Is there a way to do this with the VF template below?

VF Email Template:
<messaging:emailTemplate recipientType="Contact"
  subject="Non-Compliance Notification - {!relatedTo.Name} - {!TODAY()}"
  <messaging:htmlEmailBody >
        <STYLE type="text/css">
          TH {font-size: 11px; font-face: arial;background: #CCCCCC;
               border-width: 1;  text-align: center } 
          TD  {font-size: 11px; font-face: verdana } 
          TABLE {border: solid #CCCCCC; border-width: 1}
          TR {border: solid #CCCCCC; border-width: 1}
        <font face="arial" size="2">
          <p>Hi {!Recipient.Name},</p>
          <p>Text here......<br/></p>
          <table border="0" columns="2">
            <apex:variable value="{!1}" var="ViolationNum"/>
            <apex:repeat var="cx" value="{!relatedTo.Cases}">
            <apex:outputPanel rendered="{!IF(cx.Status = 'Escalated',TRUE,FALSE)}">
                    <td colspan="2"><b><u>Violation #<apex:outputText value="{!FLOOR(ViolationNum)}"/></u></b></td>
                    <apex:variable var="ViolationNum" value="{!ViolationNum + 1}"/>
                    <td width="25%">Site Name(s)</td>
                    <td width="75%">&nbsp;&nbsp;&nbsp;{!cx.Sample_URLs__c}</td>
                    <td width="25%">Sample URL</td>
                    <td width="75%">&nbsp;&nbsp;&nbsp;{!cx.Sample_URLs__c}</td>
                    <td width="25%">Violation Type</td>
                    <td width="75%">&nbsp;&nbsp;&nbsp;{!cx.Type_of_Violation__c}</td>
                    <td width="25%">Description of Violation</td>
                    <td width="75%">&nbsp;&nbsp;&nbsp;{!cx.Compliance_Violation_Description__c}</td>

            Please respond to this email by 
                <apex:outputText value="{0, date, MMMM d','  yyyy}">
                    <apex:param value="{!TODAY()+7}"/>