EmailTemplate
Represents a template for an email, mass email, list email, or Sales Engagement email. Supported in first-generation managed packages only.
First-generation packaging only is supported for Lightning email templates.
This type extends MetadataWithContent and inherits its fields.
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.
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:
Email templates are available in API version 12.0 and later.
- Type: double
- Required: No
- Introduced: API version 16.0
- Description: The API version if it’s a Visualforce email template. Every Visualforce email template has an API version specified at creation.
- Type: string[]
- Required: No
- Description: 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.
- Type: Attachment[]
- Required: No
- Description: A list of attachments for the email template.
- Type: boolean
- Required: Yes
- Description: Required. Indicates whether this template is offered to users when sending an email (
true) or not (false).
-
Type: base64Binary
-
Required: No
-
Description: Content of the email template. Base 64-encoded binary data. Before 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 handled for you by a SOAP client. This field contains:
- Binary content of the email body if
typeis set totext - HTML email content if
typeis set tohtml - HTML body if
typeis set tocustom - Visualforce body if
typeis set tovisualforce
This field is inherited from the MetadataWithContent component.
- Binary content of the email body if
- Type: string
- Required: No
- Description: The email template description describes the reason for creating the template.
-
Type: Encoding (enumeration of type string)
-
Required: Yes
-
Description: Required for Classic email templates. The default encoding setting is Unicode:
UTF-8. Change it if your template requires data in a different format.Valid values include:
Lightning email templates don’t use this field. Instead, the encoding values are taken directly from the user’s encoding settings.
-
Possible values:
- UTF-8 — Unicode (UTF-8)
- ISO-8859-1 — General US & Western Europe (ISO-8859–1, ISO-LATIN-1)
- Shift_JIS — Japanese (Shift-JIS)
- ISO-2022-JP — Japanese (JIS)
- EUC-JP — Japanese (EUC-JP)
- x-SJIS_0213 — Japanese (Shift-JIS_2004)
- ks_c_5601-1987 — Korean (ks_c_5601-1987)
- Big5 — Traditional Chinese (Big5)
- GB2312 — Simplified Chinese (GB2312)
- Big5-HKSCS — Traditional Chinese Hong Kong (Big5–HKSCS)
- Type: string
- Required: No
- Description: The email template developer name used as a unique identifier for API access. The
fullNamecan 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 thenamefield. This field is inherited from the Metadata component.
- Type: string
- Required: No
- Description: The letterhead name associated with this email template. Only available when
typeis set tohtml.
- Type: string
- Required: Yes
- Description: Required. Email template name. The list of characters allowed in the
fullNamefield has been reduced for versions 14.0 and later. This field contains the value contained in thefullNamefield before version 14.0.
-
Type: PackageVersion[]
-
Required: No
-
Introduced: API version 16.0
-
Description: 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 Second-Generation Managed Packages in the Salesforce DX Developer Guide.
- Type: string
- Required: No
- Type: string
- Required: No
- Description: Reserved for future use with Lightning Experience.
-
Type: EmailTemplateStyle (enumeration of type string)
-
Required: Yes
-
Description: Required. The style of the template. This field is only available when type is set to
html.Valid style values include:
-
Possible values:
- none
- freeForm
- formalLetter
- promotionRight
- promotionLeft
- newsletter
- products
-
Type: string
-
Required: No
-
Description: The email subject.
The limit is 1,000 characters for Lightning email templates and 230 characters for Classic email templates.
- Type: string
- Required: No
- Description: The text of the email body if type is set to
htmlorcustom.
- Type: EmailTemplateType (enumeration of type string)
- Required: Yes
- Description: Required. The email template type.
- Possible values:
- text — all users can create or change text email templates.
- html — administrators and users with the “Edit HTML Templates” permission can create HTML email templates based on a letterhead.
- custom — administrators and users with the “Edit HTML Templates” permission can create custom HTML email templates without using a letterhead. You must either know HTML or obtain the HTML code to insert in your email template.
- visualforce — administrators and users with the Customize Application permission can create email templates using Visualforce.
-
Type: EmailTemplateUiType (enumeration of type string)
-
Required: No
-
Description: Indicates the user interface where this template is usable.
If
UiTypeisSFX, thetypemust becustom.Packaging is supported for Salesforce Classic email templates only.
-
Possible values:
- Aloha — (Salesforce Classic)
- SFX — (Lightning Experience)
- SFX_Sample — (Lightning Experience Sample)
Attachment represents an email attachment.
- Type: base64Binary
- Required: Yes
- Description: Required. The attachment content. Base 64-encoded binary data. Before 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 handled for you by a SOAP client.
- Type: string
- Required: Yes
- Description: Required. The attachment file name.
Here’s a sample XML definition of an email template.
This metadata type doesn’t support the wildcard character * (asterisk) in the package.xml manifest file. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.