[SalesForce] Email Template HtmlValue not Returned

I have been attempting to enter an Email Template for a couple of days now. Each time I create a Visualforce email template and fill out the required fields. I then enter the body of my email and click Save. When I query for the email template using the following query:

select id, htmlvalue, body, name from emailtemplate where name = 'emailTemplateNameHere'

the htmlvalue comes back as blank despite me using <messaging:htmlEmailBody> tags in my body.

I queried again this morning to make sure nothing had changed over the weekend and the HtmlValue was still blank. I entered another Email Template, re-queried to check if it had an HTML body and saw (since I used select id, htmlvalue, body, name from emailtemplate where name like '%partOfNameHere%') that the new record had a blank HtmlValue, but the HtmlValue for my new record was blank.

It is also important to mention that when I run code that attempts to select the HtmlValue it also gets a blank value. This has been preventing me from working on a project for a few days now, does anyone have any suggestions? Thanks ahead of time!

Best Answer

Hey Jessica I was facing the same issue, and I have figured out the solution.

In order to reflect the changes, please follow the steps:

  • you have to mark Available For Use as inactive in email template properties before making the changes.
  • Do your changes whatever you want to.
  • Once you are done with your changes you can mark Available For Use active again.

Bonus: Do your changes and once you are done with your changes, just switch Available For Use to inactive, and again marking it as active will do the job.

To verify your changes:

select Id, name,subject,body,htmlValue from EmailTemplate WHERE DeveloperName = 'Template_Developer_Name'
Related Topic