Newer Version Available
EmailTemplate
Represents an email template. This metadata type extends the MetadataWithContent component and shares its fields.
File Suffix and Directory Location
The file suffix is .email for the template file. The accompanying metadata file is named EmailTemplateName-meta.xml.
EmailTemplate components are stored in the email folder in the corresponding package directory. For example, for an email template named SampleTemplate in the sampleFolder folder, there’s a SampleTemplate-meta.xml in the email/sampleFolder of the package.
Retrieving Email Templates
You can’t use the wildcard (*) symbol with email templates in package.xml. To retrieve the list of email templates for populating package.xml with explicit names, call listMetadata() and pass in EmailTemplate as the type.
The following example shows folders in package.xml:
1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3 <types>
4 <members>MyDBFolder/MyDBName</members>
5 <name>Dashboard</name>
6 </types>
7 <types>
8 <members>MyDocumentFolder/MyDocumentName</members>
9 <name>Document</name>
10 </types>
11 <types>
12 <members>unfiled$public/MarketingProductInquiryResponse</members>
13 <members>unfiled$public/SalesNewCustomerEmail</members>
14 <name>EmailTemplate</name>
15 </types>
16 <types>
17 <members>MyReportFolder/MyReportName</members>
18 <name>Report</name>
19 </types>
20 <version>35.0</version>
21</Package>Version
Email templates are available in API version 12.0 and later.
Fields
This metadata type contains the following fields:
| Field Name | Field Type | Description |
|---|---|---|
| apiVersion | double | The API version if this is a Visualforce email template. Every Visualforce email template has an API version specified at creation. This field is available in API version 16.0 and later. |
| attachedDocuments | string[] | A list of references to documents in your organization. These documents are included as attachments in the email template. Each document is referenced by its path, for example MyFolder/MyDocument.txt. |
| attachments | Attachment[] | A list of attachments for the email template. |
| available | boolean | Required. Indicates whether this template is offered to users when sending an email (true) or not (false). |
| content | base64Binary | Content of the email template. Base 64-encoded binary data. Prior to
making an API call, client applications must encode the binary attachment
data as base64. Upon receiving a response, client applications must
decode the base64 data to binary. This conversion is usually handled
for you by a SOAP client. This field contains:
This field is inherited from the MetadataWithContent component. |
| description | string | The email template description. This can be useful to describe the reason for creating the template. |
| encodingKey | Encoding (enumeration of type string) |
Required. The default encoding setting is Unicode: UTF-8. Change it if your
template requires data in a different format.
Valid values include:
|
| fullName | string | The email template developer name used as a unique identifier for API access. The fullName can contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. If this field contained characters before version 14.0 that are no longer allowed, the characters were stripped out of this field, and the previous value of the field was saved in the name field. This field is inherited from the Metadata component. |
| letterhead | string | The letterhead name associated with this email template. Only available when type is set to html. |
| name | string | Required. Email template name. The list of characters allowed in the fullName field has been reduced for versions 14.0 and later. This field contains the value contained in the fullName field before version 14.0. |
| packageVersions | PackageVersion[] |
The list of package versions
for any managed packages containing components that are referenced
by this email template. This field is only relevant for Visualforce email templates. For more information about managed packages, see the Force.com Quick Reference for Developing Packages. For more information about package versions, see “About Package Versions” in the Salesforce online help. This field is available in API version 16.0 and later. |
| style | EmailTemplateStyle (enumeration of type string) | Required. The style of the template. This field is only available
when type is set to html. Valid style values include:
|
| subject | string | The email subject. |
| textOnly | string | The text of the email body if type is set to html or custom. |
| type | EmailTemplateType (enumeration of type string) | Required. The email template type. The valid values are:
|
Attachment
Attachment represents an email attachment.
| Field | Field Type | Description |
|---|---|---|
| content | base64Binary | Required. The attachment content. Base 64-encoded binary data. Prior to making an API call, client applications must encode the binary attachment data as base64. Upon receiving a response, client applications must decode the base64 data to binary. This conversion is usually handled for you by a SOAP client. |
| name | string | Required. The attachment file name. |
Declarative Metadata Sample Definition
A sample XML definition of an email template is shown below.
1<?xml version="1.0" encoding="UTF-8"?>
2<EmailTemplate xmlns="http://soap.sforce.com/2006/04/metadata">
3 <available>true</available>
4 <description>Sample Email Template</description>
5 <encodingKey>ISO-8859-1</encodingKey>
6 <name>Sample Email Template</name>
7 <style>none</style>
8 <subject>Sample email subject</subject>
9 <textOnly>Your case has been resolved.</textOnly>
10 <type>custom</type>
11</EmailTemplate>