+ Start a Discussion
Marty LavenderMarty Lavender 

Misc table errors when attempting to create VF Email Template

I created the below code for an email template. I get misc errors regarding closing tags for certain opening tags. The closing tags are present. I am not sure why this is happening.

<body style="margin: 0; padding: 0;">
	<table border="0" cellpadding="0" cellspacing="0" width="100%">	
		<tr>
			<td style="padding: 10px 0 30px 0;">
				<table align="center" border="0" cellpadding="0" cellspacing="0" width="600" style="border: 1px solid #cccccc; border-collapse: collapse;">
					<tr>
						<td align="center" bgcolor="#fff" style="padding: 40px 0 30px 0; color: #153643; font-size: 28px; font-weight: bold; font-family: Arial, sans-serif;">
							<img src="21CT_Color_75x75.png" alt="21CT Support" width="75" height="75" style="display: block;" />
						</td>
					</tr>
					<tr>
						<td bgcolor="#ffffff" style="padding: 40px 30px 40px 30px;">
							<table border="0" cellpadding="0" cellspacing="0" width="100%">
								<tr>
									<td style="color: #153643; font-family: Arial, sans-serif; font-size: 24px;">
										<b>A new case has been opened for you</b>
									</td>
								</tr>
								<tr>
									<td style="padding: 20px 0 30px 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
										
										Dear {!Case.Contact,Sir or Madam}, </p>

  										Thank you for contacting 21CT Support. </p>

  										A new case has been created and assigned to a member of the 21CT Support team. Your case number is {!Case.Id}. </p>

 										If this case was opened via email, a member of the 21CT Support team will be contacting you shortly. If you have already spoken with a member of our support team, please feel free to respond to this email with any additional information or questions you may have regarding your support issue. </p>

  										<br/>
    									<br/>
    									<br/>
  										<br/>
    									<br/>
    									<br/>

  										<small >**When responding, please do not edit any existing text already placed in the email as this helps us track of your case.</small>

									</td>
								</tr>
								<tr>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td bgcolor="#159C91" style="padding: 30px 30px 30px 30px;">
							<table border="0" cellpadding="0" cellspacing="0" width="100%">
								<tr>
									<td style="color: #ffffff; font-family: Arial, sans-serif; font-size: 14px;" width="75%">
										&reg; 21CT 2014<br/>
									</td>
									<td align="right" width="25%">
										<table border="0" cellpadding="0" cellspacing="0">
											<tr>
												<td style="font-family: Arial, sans-serif; font-size: 12px; font-weight: bold;">
													<a href="http://www.21ct.com" style="color: #ffffff;">
														<img src="lynxeonlogo" alt="Twitter" width="38" height="38" style="display: block;" border="0" />
													</a>
												</td>
												<td style="font-size: 0; line-height: 0;" width="20">&nbsp;</td>
												<td style="font-family: Arial, sans-serif; font-size: 12px; font-weight: bold;">
													<a href="http://www.21ct.com" style="color: #ffffff;">
														<img src="torchlogo" alt="Facebook" width="38" height="38" style="display: block;" border="0" />
													</a>
												</td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</body>
</html>


Best Answer chosen by Marty Lavender
Denis VakulishinDenis Vakulishin
As I wrote you should set relatedToType = Case
And all variable will look like {!relatedTo.Contact} or {!relatedTo.Id}

All Answers

Denis VakulishinDenis Vakulishin
Hi Marty,
Try to use some html validation service.
Eg http://validator.w3.org/check
Denis VakulishinDenis Vakulishin
For example:
Dear {!Case.Contact,Sir or Madam}, </p>   -  you close tage without opening it
Marty LavenderMarty Lavender
Alright  Getting there. Code is cleaned up and it passes now as valid HTML but I am getting another error: Error: Syntax error. Missing '}'
<messaging:emailTemplate recipientType="Contact"
  relatedToType="Account"
  subject="A new 21CT Support case has been opened"
  replyTo="support@acme.com">
  <messaging:htmlEmailBody >
    <html>
      <body style="margin: 0; padding: 0;">
        <STYLE type="text/css">

        </STYLE>
<table border="0" cellpadding="0" cellspacing="0" width="100%"> 
        <tr>
            <td style="padding: 10px 0 30px 0;">
                <table align="center" border="0" cellpadding="0" cellspacing="0" width="600" style="border: 1px solid #cccccc; border-collapse: collapse;">
                    <tr>
                        <td align="center" bgcolor="#fff" style="padding: 40px 0 30px 0; color: #153643; font-size: 28px; font-weight: bold; font-family: Arial, sans-serif;">
                            <img src="21CT_Color_75x75.png" alt="21CT Support" width="75" height="75" style="display: block;" />
                        </td>
                    </tr>
                    <tr>
                        <td bgcolor="#ffffff" style="padding: 40px 30px 40px 30px;">
                            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                <tr>
                                    <td style="color: #153643; font-family: Arial, sans-serif; font-size: 24px;">
                                        <b>A new case has been opened for you</b>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="padding: 20px 0 30px 0; color: #153643; font-family: Arial, sans-serif; font-size: 16px; line-height: 20px;">
                                        
                                        <p>Dear {!Case.Contact,Sir or Madam}, </p>

                                        <p>Thank you for contacting 21CT Support. </p>

                                        <p>A new case has been created and assigned to a member of the 21CT Support team. Your case number is {!Case.Id}. </p>

                                        <p>If this case was opened via email, a member of the 21CT Support team will be contacting you shortly. If you have already spoken with a member of our support team, please feel free to respond to this email with any additional information or questions you may have regarding your support issue. </p>

                                        <br/>
                                        <br/>
                                        <br/>
                                        <br/>
                                        <br/>
                                        <br/>

                                        <small >**When responding, please do not edit any existing text already placed in the email as this helps us track of your case.</small>

                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td bgcolor="#159C91" style="padding: 30px 30px 30px 30px;">
                            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                <tr>
                                    <td style="color: #ffffff; font-family: Arial, sans-serif; font-size: 14px;" width="75%">
                                        &reg; 21CT 2014<br/>
                                    </td>
                                    <td align="right" width="25%">
                                        <table border="0" cellpadding="0" cellspacing="0">
                                            <tr>
                                                <td style="font-family: Arial, sans-serif; font-size: 12px; font-weight: bold;">
                                                    <a href="http://www.21ct.com" style="color: #ffffff;">
                                                        <img src="lynxeonlogo" alt="Twitter" width="38" height="38" style="display: block;" border="0" />
                                                    </a>
                                                </td>
                                                <td style="font-size: 0; line-height: 0;" width="20">&nbsp;</td>
                                                <td style="font-family: Arial, sans-serif; font-size: 12px; font-weight: bold;">
                                                    <a href="http://www.21ct.com" style="color: #ffffff;">
                                                        <img src="torchlogo" alt="Facebook" width="38" height="38" style="display: block;" border="0" />
                                                    </a>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>


      </body>
    </html>
  </messaging:htmlEmailBody> 
  <messaging:plainTextEmailBody >
    Dear {!recipient.name},
 
    For more information login to the 21CT Support Portal (http://21ct.force.com/support)
  </messaging:plainTextEmailBody>    
</messaging:emailTemplate>


Denis VakulishinDenis Vakulishin
{!Case.Contact,Sir or Madam}

I think should be like {!Case.Contact},Sir or Madam
Denis VakulishinDenis Vakulishin
And one more thing, are you sure, that relatedToType should be Account, maybe you it should be Case.
If yes, then fix code from {!Case. to {!retatedTo.
Marty LavenderMarty Lavender
It should be case. That is correct.

For some reason when I have 

{!Case.Contact,Sir or Madam} and {!CaseiD} in the template, I get this error: Error: Unknown property 'core.email.template.EmailTemplateComponentController.Case'

If I take those variables out, I can save the template with no error.
Denis VakulishinDenis Vakulishin
As I wrote you should set relatedToType = Case
And all variable will look like {!relatedTo.Contact} or {!relatedTo.Id}
This was selected as the best answer
Marty LavenderMarty Lavender
That worked!  Thank you so much.  I was missing the relatedTo for the variables.
Denis VakulishinDenis Vakulishin
Could you mark this question as Resolved?
Thanks.