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
Warren WadeWarren Wade 

Visualforce Error: "Invalid child of messaging:emailTemplate."

I'm receiving the following error for what I hope will be a simple Case Created Email Template:
Only messaging components are allowed as children of messaging:emailTemplate.

Below is my VF Template.  Any help would be appreciated.  I'm new to writing apex.
<messaging:emailTemplate 
    subject="Test Case Creation" 
    recipientType="Contact" 
    relatedToType="Case">
    replyTo="email@address.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>
            <p>This is an automated confirmation to confirm that we have received your case.&nbsp; When you receive future emails regarding this case, please respond directly to that email thread. In doing so, you will ensure that your email is logged against the appropriate case. </p>
            <TABLE border="0">
                <TR>
                  <TD>Case Number</TD>
                  <TD><apex:outputtext>"{!relatedTo.CaseNumber}"</apex:outputtext></TD>
                </TR>
                <TR>
                  <TD>Subject</TD>
                  <TD><apex:outputtext> value="{!relatedTo.Subject}"</apex:outputtext></TD>
                </TR>
                <TR>
                  <TD>Priority</TD>
                  <TD><apex:outputtext> value="{!relatedTo.Priority}"</apex:outputtext></TD>
                </TR>
                <TR>
                  <TD>Description</TD>
                  <TD><apex:outputtext> value="{!relatedTo.Description}" </apex:outputtext></TD>
                </TR>
                <TR>
                  <TD>Reference Code</TD>
                  <TD><apex:outputtext> value="{!relatedTo.Reference_Field__c}" </apex:outputtext> </TD>
                </TR>
            </TABLE>
            <p>You can expect a response from our staff member within 2 business days. Our goal is to resolve your case within 5 working days depending on the level of complexity and urgency. If you wish to Escalate this case, please respond to this or an email within the cases thread with the subject &quot;Escalate&quot;.</p>
            </body>
        </html>
    </messaging:htmlEmailBody>>
</messaging:emailTemplate>

 
Lalit Mistry 21Lalit Mistry 21
Hi Warren,
Try with below code. That should help
<messaging:emailTemplate 
    subject="Test Case Creation" 
    recipientType="Contact" 
    relatedToType="Case"
    replyTo="email@address.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>
            <p>This is an automated confirmation to confirm that we have received your case.&nbsp; When you receive future emails regarding this case, please respond directly to that email thread. In doing so, you will ensure that your email is logged against the appropriate case. </p>
            <TABLE border="0">
                <TR>
                  <TD>Case Number</TD>
                  <TD><apex:outputtext value="{!relatedTo.CaseNumber}"/></TD>
                </TR>
                <TR>
                  <TD>Subject</TD>
                  <TD><apex:outputtext value="{!relatedTo.Subject}"/></TD>
                </TR>
                <TR>
                  <TD>Priority</TD>
                  <TD><apex:outputtext value="{!relatedTo.Priority}"/></TD>
                </TR>
                <TR>
                  <TD>Description</TD>
                  <TD><apex:outputtext value="{!relatedTo.Description}"/></TD>
                </TR>
                
            </TABLE>
            <p>You can expect a response from our staff member within 2 business days. Our goal is to resolve your case within 5 working days depending on the level of complexity and urgency. If you wish to Escalate this case, please respond to this or an email within the cases thread with the subject &quot;Escalate&quot;.</p>
            </body>
        </html>
    </messaging:htmlEmailBody>
</messaging:emailTemplate>

 
Warren WadeWarren Wade
Hi, Lalit - 

Thanks for your response.  I inserted your code and noticed that you added some lines for the reference field; however, the issue I'm currently facing is the error message (below).  
Error: Invalid child of messaging:emailTemplate. Only messaging components are allowed as children of messaging:emailTemplate.
Do you have any insight into this error?  
 
Lalit Mistry 21Lalit Mistry 21
Hi Warren,

If you closely look at the visualforce template that you initially posted, you'll find that template is not correctly compiled because of some typo's like 
<apex:outputtext> value="{!relatedTo.Subject}"</apex:outputtext>
In the example above, value attribute is not placed correctly, i.e. it should be part of the outputtext tag and not placed between the start and close outputtext tags.
Similarly, you have few more typo's in your template and hence you get this error.
Hope that answers your question.