function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MWelch_WTMWelch_WT 

Strange behavior with VF emailTemplate SOQL query

I'm trying to massage a VF email template a little bit in Apex, and am seeing some strange behavior with the emailTemplate standard object.  I use the following Apex code to grab the id, body, and markup of a VF template:

 

 

emailTemplate et = [SELECT id, body, markup, htmlvalue, templatestyle, templatetype from emailtemplate where name='Basic Inquiry Template']; templateBody=et.id+'<br>'+et.body+'<br>'+et.markup;

 

On the following VF email template:

 

 

<messaging:emailTemplate subject="Test Subject" recipientType="Contact" relatedToType="Account" > <messaging:plainTextEmailBody > Test plain Text Body. </messaging:plainTextEmailBody> </messaging:emailTemplate>

 

 When I look at the result, et.id is correct, and et.markup is correct, but et.body, which I would expect to read "Test plain Text Body." instead reads "Congratulations! This is your new Visualforce Email Template." which is the default text from when you first create a new VF email template.  I deleted that long ago!

 

One added data point is that the template, when invoked from a "Send an Email" page, works as expected, inserting "Test plain Text Body" in the body of the email.

 

Any ideas what's going on here?