1

I tried to use an tag in a visualforce email template and got the following:

Error: <messaging:emailTemplate> cannot contain <apex:dynamicComponent>

Is there any way to get around this or is dynamic visualforce impossible in email templates?

My use case is supporting multiple languages in one email template and allowing the users to modify the text of the email without having to modify the email template.

The users would have a separate object with a long text area where they would enter the text of the email (using visualforce merge fields) as well as translations of that text and then the email template would just have references to that object and would pick the correct translation based on the language of the email recipient. Basically custom labels on steroids.

1

I'm guessing that it's not possible, though I'd confirm that you're using the latest API version to be sure. But VF email templates have always been a subset of Visualforce, with various limitations. From pg 184 of the Summer '12 Visualforce manual:

Although Visualforce email templates use standard Visualforce components, they are not created in the same way. Visualforce email templates always use components that are prefaced with the messaging namespace. In addition:

• All Visualforce email templates must be contained within a single <messaging:emailTemplate> tag. This is analogous to regular Visualforce pages being defined within a single <apex:page> tag.

• The <messaging:emailTemplate> tag must contain either a single <messaging:htmlEmailBody> tag or a single <messaging:plainTextEmailBody> tag.

• Several standard Visualforce components are not available for use within <messaging:emailTemplate>. These include <apex:detail>, <apex:pageBlock> and all related pageBlock components, and all input components such as <apex:form>. If you attempt to save a Visualforce email template with these components, an error message displays.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.