---
schema_version: "1"
id: 8a81876a984dc9badfc7cec6131179093ce016d2450fee23aa7a3278aee8b51a
title: messaging:attachment
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-pages-developers-guide/guides/pages/components/pages-compref-messaging-attachment.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/guide/pages-compref-messaging-attachment.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: a25c49a1d692a7038e457491028aa039c68cc22bea41fe22a7baa0ef03b2c555
products:
  - Visualforce Developer Guide
  - Platform Developer Content
---

# messaging:attachment

Compose an attachment and append it to the email.

## Example

```apex
<messaging:emailTemplate recipientType="Contact"
	relatedToType="Account"
	subject="Case report for Account: {!relatedTo.name}"
	replyTo="support@example.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="https://salesforce.com">
			For more detailed information log in 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 isn’t provided, one is generated for you.                                                                                                                                                                                                                                                                                                                                              |           | 14.0        |        |
| `id`           | String         | An identifier that other components in the page use to reference the attachment component.                                                                                                                                                                                                                                                                                                                                               |           | 14.0        | global |
| `inline`       | Boolean        | Sets the HTTP `Content-Disposition` header of the attachment in the email to `inline`.                                                                                                                                                                                                                                                                                                                                                   |           | 17.0        |        |
| `renderAs`     | String         | Indicates how the attachment is rendered. The default value is `"text"`.Although any MIME type/subtype is a valid `renderAs` value, Visualforce supports [content conversion](https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/styling/pages-output-pdf-renderas.md) of only PDFs.Visualforce doesn’t generate other file formats. It only sets the `Content-Type` field of the HTTP response header to the specified MIME type. Some file formats, such as .xlsx, can fail to render. |           | 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 |

**See Also**

- [Visualforce Email Templates](https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/email-and-templates/pages-email-templates-intro.md)
- [Add Attachments to a Visualforce Email Template](https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/email-and-templates/pages-email-templates-attachments.md)
