Skip to main content

Why changing an email template's type doesn't apply after a successful deployment

Your change isn't applied after a successful deployment, because the Metadata API can't convert an existing email template between Text, HTML, Custom, and Visualforce.

Written by Sam Wilson

A customer raised this with us, and Salesforce confirmed the limitation to them directly. At the time of writing, it isn't mentioned in the EmailTemplate documentation.

When you create an email template, Salesforce fixes its type at that moment, and there's no way to change it later.

If you try to change the type through Gearset, or any other tool that uses the Metadata API, the deployment won't stop you. The API accepts the change without raising a validation error, so the deployment comes back successful, but the email template in the target org stays untouched.

You'll only discover this afterwards: when you check the target org manually, or when you rerun the comparison and find the template still flagged as Different.

Why it happens

type is a required field, and it takes one of four values: text, html, custom or visualforce. Everything else about the template is shaped by that choice.

  • style and letterhead apply to HTML templates only

  • apiVersion applies to Visualforce templates only, and is set when the template is created

  • content holds something completely different in each case: plain text, HTML, or Visualforce markup

Switching the type would therefore mean rebuilding the component from scratch, which is presumably why Salesforce treats it as fixed. The UI reflects this too, in that you choose a type when you create a template and the option never appears again.

Did this answer your question?