I'm creating a UI that feeds into an email template via visualforce. One of the features I want to add is the user should be able to click checkboxes and add attachments to an email template. When the user clicks a button to get to the constructed email template, those attachments are added.

From the UI part, I have the attachment ID's, but i don't know how to get those multiple attachments added to the email template. Also, you can't do <apex:repeat> on <messaging:attachment>

A couple of constraints - 1- The attachments could be any type - .gif, .pdf, .csv 2- I'd like the attachments to have their actual names 3- what ever the file type is, i'd like it to stay that way 4- I'd prefer not to do a batch apex

There is a related q here: Using a component to add attachments to visualforce email template and showing email link

1 Answer 1


after much research, it doesn't look this can be done. The only real option is to put all the attachments together as one attachment.

it looks like the only way you can add multiple attachments is when you know the number of attachments (or potential #) ahead of time. if you do you then you can create those elements in the email template

<messaging:attachment rendered="(some criteria)" >
<messaging:attachment rendered="(some criteria)" >

You must log in to answer this question.

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