Similar to how we can use apex to get the blob value of a VisualForce page, can we also do this on a VisualForce Email Template? We need to get the rendered template into an attachment record in Salesforce.
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
One approach might be to factor the bulk of your Email Template code (which of course is just VF markup anyway) into a Visualforce Component. Thus enabling you to share it by referencing this component between a Visualforce Page (to enable you to capture it on your attachments) and Email Templates (for when your emailing). For example.
Your email template would look like this...
Your VF page would look like this...
Hope this helps!
Note: Note that Visualforce Components when delivered in Managed Packages are none editable, unlike Email Templates. You can work around this though, by copy and pasting the component code into a new one in the subscriber code and changing the template to point to the new component.
Select e.TemplateType, e.TemplateStyle, e.Subject, e.Name, e.Id, e.Body From EmailTemplate e
I tried this with this query .For Visualforce Email template I did not get anything in Body while for Text Template we get the body.
Hence i dont think it will be possible to extract data as blob for visualforce email template