I have a VF page set up as an email template. I have a repeat tag on the HTML part of my template that pulls in Cases based upon some criteria contained in an OutputPanel. I am trying to accomplish the same thing on the Plain Text version of my template, but when I try to put in an outputPanel I get an error:

messaging:plainTextEmailBody> cannot contain <apex:outputPanel

Does anyone know how I can get a render attribute inside my Repeat attribute for the plain text email body?

1 Answer 1


Since messaging:plainTextEmailBody can't have HTML, and, an outputPanel is a div or span and hence it won't work. So, how to work around?

Option 1: Use a custom component w/ controller

So, assuming you are getting Cases for an Account:

Create a custom component <c:theCases accountId={!someAcctMergeField}/>

The custom component would:

  1. Be associated with a controller
  2. Do the filtering in the controller based on values passed through the component's attributes and/or queried from the database
  3. Return a list of Cases ...
  4. That are the value={!...} attribute of the repeat and ...
  5. Can be rendered as HTML in the HtmlEmailBody and as plain text in the plainTextEmailBody

That is, move the rendering logic out to the custom component's controller

Update: You could also use the rendered= attribute on the <c:myCustomComponent ..> to decide to render the component at all (in effect, acting like the outputPanel rendered= )

Option 2 - move the rendering condition onto the apex:repeat (if possible)

You must log in to answer this question.

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