messaging:attachment

Compose an attachment and append it to the email.

Example

<messaging:emailTemplate recipientType="Contact"
                        
relatedToType="Account"
subject="Case report for Account: {!relatedTo.name}"
replyTo="support@acme.com"> <messaging:htmlEmailBody> <html> <body> <p>Dear {!recipient.name},</p> <p>Attached is a list of cases related to {!relatedTo.name}.</p> <center> <apex:outputLink value="http://www.salesforce.com"> For more detailed information login to Salesforce.com </apex:outputLink> </center> </body> </html> </messaging:htmlEmailBody> <messaging:attachment renderAs="PDF" filename="yourCases.pdf"> <html> <body> <p>You can display your {!relatedTo.name} cases as a PDF</p> <table border="0" > <tr> <th>Case Number</th><th>Origin</th> <th>Creator Email</th><th>Status</th> </tr> <apex:repeat var="cx" value="{!relatedTo.Cases}"> <tr> <td><a href = "https://na1.salesforce.com/{!cx.id}">{!cx.CaseNumber}
</a></td> <td>{!cx.Origin}</td> <td>{!cx.Contact.email}</td> <td>{!cx.Status}</td> </tr> </apex:repeat> </table> </body> </html> </messaging:attachment> </messaging:emailTemplate>

Attributes

Attribute Name Attribute Type Description Required? API Version Access
filename String Sets a file name on the attachment. If a filename is not provided, one will be generated for you. 14.0
id String An identifier that allows the attachment component to be referenced by other components in the page. 14.0 global
inline Boolean Sets the content-disposition of the attachment in the email to Inline. 17.0
renderAs String Indicates how the attachment should be rendered. Valid values are any mime type/subtype. The default value is 'text'. 14.0
rendered Boolean A Boolean value that specifies whether the component is rendered on the page. If not specified, this value defaults to true. 14.0 global
© Copyright 2000–2014 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.