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
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"
  relatedToType="Account"
  subject="Non-Compliance Notification - {!relatedTo.Name} - {!TODAY()}"
  replyTo="test@test.com">
  <messaging:htmlEmailBody >
    <html>
      <body>
        <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}
        </STYLE>
        <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)}">
                <tr>
                    <td colspan="2"><b><u>Violation #<apex:outputText value="{!FLOOR(ViolationNum)}"/></u></b></td>
                    <apex:variable var="ViolationNum" value="{!ViolationNum + 1}"/>
                </tr>
                <tr>
                    <td width="25%">Site Name(s)</td>
                    <td width="75%">&nbsp;&nbsp;&nbsp;{!cx.Sample_URLs__c}</td>
                </tr>
                <tr>
                    <td width="25%">Sample URL</td>
                    <td width="75%">&nbsp;&nbsp;&nbsp;{!cx.Sample_URLs__c}</td>
                </tr>
                <tr>
                    <td width="25%">Violation Type</td>
                    <td width="75%">&nbsp;&nbsp;&nbsp;{!cx.Type_of_Violation__c}</td>
                </tr>
                <tr>
                    <td width="25%">Description of Violation</td>
                    <td width="75%">&nbsp;&nbsp;&nbsp;{!cx.Compliance_Violation_Description__c}</td>
                </tr>
                <br/><br/>
            </apex:outputPanel>
            </apex:repeat>
            </Table>

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