0

I'm trying to understand the VisualForce code below to see what was written & is causing the error above:

<messaging:emailTemplate subject="Your Offering Listing"
    recipientType="Contact"
    relatedToType="vlocity_ps__InventoryItem__c">

<messaging:htmlEmailBody>
 <html>
   <body>

<p> Congratulations! </p>
<p> This is your new Visualforce Email Template, which displays the photos relating to your listing. </p>

   </body>
 </html>
</messaging:htmlEmailBody>

<center>
<apex:outputLink value="https://dev-xyz.cs20.force.com">
   For more detailed information login to the Portal here to see your listing.
</apex:outputLink>
</center>

</messaging:emailTemplate>

The goal is to add attachments from an object record to the E-Mail template under the "Congratulations" verbiage. However, in order to do this I need to fix this error first, which is displayed when trying to save the VF E-Mail template.

"Error: Invalid child of messaging:emailTemplate. Only messaging components are allowed as children of messaging:emailTemplate."

I'm looking for advice on:

  1. The error above.
  2. How to add attachments from an object record's "Attachments" related list.

1 Answer 1

3

As the error says, you can't put other markup outside of the messaging elements. Here's the fix:

<messaging:emailTemplate subject="Your Offering Listing"
    recipientType="Contact"
    relatedToType="vlocity_ps__InventoryItem__c">

<messaging:htmlEmailBody>
 <html>
   <body>

<p> Congratulations! </p>
<p> This is your new Visualforce Email Template, which displays the photos relating to your listing. </p>

<center>
<apex:outputLink value="https://dev-xyz.cs20.force.com">
   For more detailed information login to the Portal here to see your listing.
</apex:outputLink>
</center>
   </body>
 </html>
</messaging:htmlEmailBody>


</messaging:emailTemplate>
1
  • Thank you so much sfdcfox! That worked perfectly! The answer was so obvious yet I was clearly overlooking it. So much to learn still. Do you by chance have any insight into the 2nd question: "How to add attachments from an object record's "Attachments" related list to a VF E-Mail template." I would be happy to provide more details if required (ie. To start: We would like to display images [visually] in the template. However a caveat is that that record is for an object which is part of a managed package [not sure if that matters at this point]). Thanks again sfdcfox for your time & help!
    – Samuel
    Commented Apr 6, 2018 at 15:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .