---
schema_version: "1"
id: ce3e44abb141df9b9fbff512f4c9b1f73cc2513d9fb118dde55cac39ef79ff17
title: EmailTemplate
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_meta/meta_emailtemplate.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_emailtemplate.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 87c438b3f0d82af6f7ef4e4e6ff989786cff00d729849dc52bf9f34bc56d1989
description: Represents a template for an email, mass email, list email, or Sales Engagement email. Supported in first-generation managed packages only.
---
# EmailTemplate

Represents a template for an email, mass email, list email, or Sales Engagement email. Supported in first-generation managed packages only.

This type extends the [MetadataWithContent](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_metadatawithcontent.htm "MetadataWithContent is the base type for all metadata types that contain content, such as documents or email templates. It extends Metadata. You can’t edit this object.") metadata type and inherits its content and fullName fields.

![Note](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/images/icon_note.png)

#### Note

First-generation packaging only is supported for Lightning email templates.

## 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:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types\>
        <members\>MyDBFolder/MyDBName</members\>
        <name\>Dashboard</name\>
    </types\>
    <types\>
        <members\>MyDocumentFolder/MyDocumentName</members\>
        <name\>Document</name\>
    </types\>
    <types\>
        <members\>unfiled$public/MarketingProductInquiryResponse</members\>
        <members\>unfiled$public/SalesNewCustomerEmail</members\>
        <name\>EmailTemplate</name\>
    </types\>
    <types\>
        <members\>MyReportFolder/MyReportName</members\>
        <name\>Report</name\>
    </types\>
    <version\>68.0</version\>
</Package\>

## Version

Email templates are available in API version 12.0 and later.

## Fields

This metadata type contains the following fields:

<table class="featureTable sort_table" summary="">



          <thead class="thead sorted" align="left">
            <tr>
              <th class="featureTableHeader  " id="d412456e155">Field Name</th>

              <th class="featureTableHeader  " id="d412456e158">Field Type</th>

              <th class="featureTableHeader  " id="d412456e161">Description</th>

            </tr>

          </thead>

          <tbody class="tbody">
            <tr>
              <td class="entry" headers="d412456e155" data-title="Field Name"><span class="keyword parmname" id="field_apiVersion"><a name="field_apiVersion"><!-- --></a>apiVersion</span></td>

              <td class="entry" headers="d412456e158" data-title="Field Type">double</td>

              <td class="entry" headers="d412456e161" data-title="Description">
                <span class="ph" id="field_apiVersion_desc"><a name="field_apiVersion_desc"><!-- --></a>The API version if it's a
                  Visualforce email template. Every Visualforce email template has
                  an API version specified at creation.</span> This field is
                available in API version 16.0 and later.
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d412456e155" data-title="Field Name"><span class="keyword parmname">attachedDocuments</span></td>

              <td class="entry" headers="d412456e158" data-title="Field Type">string[]</td>

              <td class="entry" headers="d412456e161" data-title="Description"><span class="ph" id="field_attachedDocuments_desc"><a name="field_attachedDocuments_desc"><!-- --></a>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
                  <span class="ph filepath">MyFolder/MyDocument.txt</span>.</span></td>

            </tr>

            <tr>
              <td class="entry" headers="d412456e155" data-title="Field Name"><span class="keyword parmname">attachments</span></td>

              <td class="entry" headers="d412456e158" data-title="Field Type">
                <a class="xref" href="#attachment">Attachment</a>[]
              </td>

              <td class="entry" headers="d412456e161" data-title="Description"><span class="ph" id="field_attachments_desc"><a name="field_attachments_desc"><!-- --></a>A list of attachments for the
                  email template.</span></td>

            </tr>

            <tr>
              <td class="entry" headers="d412456e155" data-title="Field Name"><span class="keyword parmname">available</span></td>

              <td class="entry" headers="d412456e158" data-title="Field Type">boolean</td>

              <td class="entry" headers="d412456e161" data-title="Description">Required. Indicates whether this template is offered to users
                when sending an email (<samp class="codeph java">true</samp>) or
                not (<samp class="codeph java">false</samp>).</td>

            </tr>

            <tr>
              <td class="entry" headers="d412456e155" data-title="Field Name"><span class="keyword parmname">content</span></td>

              <td class="entry" headers="d412456e158" data-title="Field Type">base64Binary</td>

              <td class="entry" headers="d412456e161" data-title="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:<ul class="ul bulletList">
                  <li class="li">Binary content of the email body if <a class="xref" href="#emailtemplate_type"><span class="keyword parmname">type</span></a> is
                    set to <samp class="codeph nolang">text</samp>
                  </li>

                  <li class="li">HTML email content if <a class="xref" href="#emailtemplate_type"><span class="keyword parmname">type</span></a> is
                    set to <samp class="codeph nolang">html</samp>
                  </li>

                  <li class="li">HTML body if <a class="xref" href="#emailtemplate_type"><span class="keyword parmname">type</span></a> is
                    set to <samp class="codeph nolang">custom</samp>
                  </li>

                  <li class="li">Visualforce body if <a class="xref" href="#emailtemplate_type"><span class="keyword parmname">type</span></a> is
                    set to <samp class="codeph nolang">visualforce</samp>
                  </li>

                </ul>
                <p class="p">This field is inherited from the <a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_metadatawithcontent.htm" title="MetadataWithContent is the base type for all metadata types that contain content, such as documents or email templates. It extends Metadata. You can’t edit this object.">MetadataWithContent</a> component.</p>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d412456e155" data-title="Field Name"><span class="keyword parmname">description</span></td>

              <td class="entry" headers="d412456e158" data-title="Field Type">string</td>

              <td class="entry" headers="d412456e161" data-title="Description">The email template description describes the reason for creating
                the template.</td>

            </tr>

            <tr>
              <td class="entry" headers="d412456e155" data-title="Field Name"><span class="ph" id="encodingKey_field_name"><a name="encodingKey_field_name"><!-- --></a><span class="keyword parmname">encodingKey</span></span></td>

              <td class="entry" headers="d412456e158" data-title="Field Type">
                <span class="ph" id="encodingKey_field_type"><a name="encodingKey_field_type"><!-- --></a>Encoding</span>
                (<a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_objects_intro.htm#enumeration_title">enumeration</a> of type string)
              </td>

              <td class="entry" headers="d412456e161" data-title="Description">
                <span class="ph" id="encodingKey_content_1"><a name="encodingKey_content_1"><!-- --></a>Required for Classic email
                  templates. The default encoding setting is Unicode: <samp class="codeph xml">UTF-8</samp>.</span> Change it if your
                template requires data in a different format.<p class="p">Valid values
                  include:</p>
                <ul class="ul bulletList">
                  <li class="li">
                    <samp class="codeph nolang">UTF-8</samp>—Unicode (UTF-8)
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">ISO-8859-1</samp>—General US &amp; Western Europe
                    (ISO-8859–1, ISO-LATIN-1)
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">Shift_JIS</samp>—Japanese (Shift-JIS)
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">ISO-2022-JP</samp>—Japanese (JIS)
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">EUC-JP</samp>—Japanese (EUC-JP)
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">x-SJIS_0213</samp>—Japanese (Shift-JIS_2004)
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">ks_c_5601-1987</samp>—Korean (ks_c_5601-1987)
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">Big5</samp>—Traditional Chinese (Big5)
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">GB2312</samp>—Simplified Chinese (GB2312)
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">Big5-HKSCS</samp>—Traditional Chinese Hong Kong
                    (Big5–HKSCS)
                  </li>

                </ul>

                <p class="p">Lightning email templates don’t use this field. Instead, the
                  encoding values are taken directly from the user’s encoding
                  settings.</p>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d412456e155" data-title="Field Name"><span class="keyword parmname" id="emailtemplate_fullName"><a name="emailtemplate_fullName"><!-- --></a>fullName</span></td>

              <td class="entry" headers="d412456e158" data-title="Field Type">string</td>

              <td class="entry" headers="d412456e161" data-title="Description">The email template developer name used as a unique identifier for
                API access. The <span class="keyword parmname">fullName</span> 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 <a class="xref" href="#emailtemplate_name"><span class="keyword parmname">name</span></a> field. This
                field is inherited from the <a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/metadata.htm" title="The base class for all metadata types. You can’t edit this object. A component is an instance of a metadata type.">Metadata</a> component.</td>

            </tr>

            <tr>
              <td class="entry" headers="d412456e155" data-title="Field Name"><span class="keyword parmname">letterhead</span></td>

              <td class="entry" headers="d412456e158" data-title="Field Type">string</td>

              <td class="entry" headers="d412456e161" data-title="Description">The letterhead name associated with this email template. Only
                available when <a class="xref" href="#emailtemplate_type"><span class="keyword parmname">type</span></a> is set to
                <samp class="codeph nolang">html</samp>.
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d412456e155" data-title="Field Name"><span class="keyword parmname" id="emailtemplate_name"><a name="emailtemplate_name"><!-- --></a>name</span></td>

              <td class="entry" headers="d412456e158" data-title="Field Type">string</td>

              <td class="entry" headers="d412456e161" data-title="Description">Required. Email template name. The list of characters allowed in
                the <a class="xref" href="#emailtemplate_fullName"><span class="keyword parmname">fullName</span></a> field
                has been reduced for versions 14.0 and later. This field contains
                the value contained in the <a class="xref" href="#emailtemplate_fullName"><span class="keyword parmname">fullName</span></a> field
                before version 14.0.</td>

            </tr>

            <tr>
              <td class="entry" headers="d412456e155" data-title="Field Name"><span class="keyword parmname" id="field_packageVersions"><a name="field_packageVersions"><!-- --></a>packageVersions</span></td>

              <td class="entry" headers="d412456e158" data-title="Field Type">
                <a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_classes.htm#PackageVersion">PackageVersion</a>[]
              </td>

              <td class="entry" headers="d412456e161" data-title="Description">
                <span class="ph" id="field_packageVersions_desc"><a name="field_packageVersions_desc"><!-- --></a>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.</span>
                <p class="p">For more information about managed
                  packages, see <a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.264.0.sfdx_dev.meta/sfdx_dev/sfdx_dev_dev2gp.htm" target="_blank" title="HTML (New Window)">Second-Generation Managed
                    Packages</a> in the <cite class="cite">Salesforce DX Developer
                    Guide</cite>. This field is available in API version 16.0
                  and later.</p>

              </td>

            </tr>

            <tr>
              <td class="entry" headers="d412456e155" data-title="Field Name"><span class="keyword parmname">relatedEntityType</span></td>

              <td class="entry" headers="d412456e158" data-title="Field Type">Object Name (<a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_objects_intro.htm#enumeration_title">enumeration</a> of type string)</td>

              <td class="entry" headers="d412456e161" data-title="Description">Reserved for future use with Lightning Experience.</td>

            </tr>

            <tr>
              <td class="entry" headers="d412456e155" data-title="Field Name"><span class="keyword parmname">style</span></td>

              <td class="entry" headers="d412456e158" data-title="Field Type">EmailTemplateStyle (<a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_objects_intro.htm#enumeration_title">enumeration</a> of type string)</td>

              <td class="entry" headers="d412456e161" data-title="Description">Required. The style of the template. This field is only available
                when <a class="xref" href="#emailtemplate_type">type</a> is set to <samp class="codeph nolang">html</samp>.<p class="p">Valid style values include:</p>
                <ul class="ul bulletList">
                  <li class="li"><samp class="codeph nolang">none</samp></li>

                  <li class="li"><samp class="codeph nolang">freeForm</samp></li>

                  <li class="li"><samp class="codeph nolang">formalLetter</samp></li>

                  <li class="li"><samp class="codeph nolang">promotionRight</samp></li>

                  <li class="li"><samp class="codeph nolang">promotionLeft</samp></li>

                  <li class="li"><samp class="codeph nolang">newsletter</samp></li>

                  <li class="li"><samp class="codeph nolang">products</samp></li>

                </ul>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d412456e155" data-title="Field Name"><span class="keyword parmname">subject</span></td>

              <td class="entry" headers="d412456e158" data-title="Field Type">string</td>

              <td class="entry" headers="d412456e161" data-title="Description">The email subject.<p class="p">The limit is 1,000 characters for Lightning
                  email templates and 230 characters for Classic email
                  templates.</p>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d412456e155" data-title="Field Name"><span class="keyword parmname">textOnly</span></td>

              <td class="entry" headers="d412456e158" data-title="Field Type">string</td>

              <td class="entry" headers="d412456e161" data-title="Description">The text of the email body if <a class="xref" href="#emailtemplate_type">type</a> is set to <samp class="codeph nolang">html</samp> or
                <samp class="codeph nolang">custom</samp>.
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d412456e155" data-title="Field Name"><span class="keyword parmname" id="emailtemplate_type"><a name="emailtemplate_type"><!-- --></a>type</span></td>

              <td class="entry" headers="d412456e158" data-title="Field Type">EmailTemplateType (<a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_objects_intro.htm#enumeration_title">enumeration</a> of type string)</td>

              <td class="entry" headers="d412456e161" data-title="Description">Required. The email template type.<p class="p"> The valid values are:</p>
                <ul class="ul bulletList">
                  <li class="li">
                    <samp class="codeph nolang">text</samp> - all users can
                    create or change text email templates.
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">html</samp> - administrators
                    and users with the “Edit HTML Templates”
                    permission can create HTML email templates based on a
                    letterhead.
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">custom</samp> - 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.
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">visualforce</samp> -
                    administrators and users with the Customize
                    Application permission can create email templates
                    using Visualforce.
                  </li>

                </ul>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d412456e155" data-title="Field Name"><span class="keyword parmname">UiType</span></td>

              <td class="entry" headers="d412456e158" data-title="Field Type">EmailTemplateUiType (<a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_objects_intro.htm#enumeration_title">enumeration</a> of type string)</td>

              <td class="entry" headers="d412456e161" data-title="Description">Indicates the user interface where this template is usable. Valid
                values are:<ul class="ul bulletList">
                  <li class="li">
                    <samp class="codeph nolang">Aloha</samp> (Salesforce
                    Classic)
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">SFX</samp> (Lightning
                    Experience)
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">SFX_Sample</samp> (Lightning
                    Experience Sample)
                  </li>

                </ul>
                <p class="p">If <span class="keyword parmname">UiType</span> is <samp class="codeph nolang">SFX</samp>, the
                  <span class="keyword parmname">type</span> must be
                  <span class="keyword parmname">custom</span>.
                </p>

                <p class="p">Packaging is supported for Salesforce Classic email templates only.</p>
              </td>

            </tr>

          </tbody>

        </table>

## Example

<EmailTemplate\>
    <available\>true</available\>
    <description\>Notification that user has been added to a community.</description\>
    <encodingKey\>UTF-8</encodingKey\>
    <name\>Communities: New Member Welcome Email</name\>
    <style\>none</style\>
    <subject\>Welcome to {!Community\_Name}</subject\>
    <type\>custom</type\>
    <uiType\>Aloha</uiType\>
</EmailTemplate\>

## Attachment

Attachment represents an email attachment.

| Field | Field Type | Description |
| --- | --- | --- |
| content | base64Binary | 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. |
| name | string | Required. The attachment file name. |

## Declarative Metadata Sample Definition

Here's a sample XML definition of an email template.

<?xml version="1.0" encoding="UTF-8"?>
<EmailTemplate xmlns="http://soap.sforce.com/2006/04/metadata">
    <available\>true</available\>
    <description\>Sample Email Template</description\>
    <encodingKey\>ISO-8859-1</encodingKey\>
    <name\>Sample Email Template</name\>
    <style\>none</style\>
    <subject\>Sample email subject</subject\>
    <textOnly\>Your case has been resolved.</textOnly\>
    <type\>custom</type\>
</EmailTemplate\>

## Wildcard Support in the Manifest File

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](https://developer.salesforce.com/docs/atlas.en-us.264.0.api_meta.meta/api_meta/file_based_zip_file.htm).

#### See Also

- [Letterhead](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_letterhead.htm "Represents formatting options for the letterhead in an email template. A letterhead defines the logo, page color, and text settings for your HTML email templates. Use letterheads to ensure a consistent look and feel in your company’s emails.")