+ Start a Discussion

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?