I am developing a feature to send a email from a Custom Visualforce page.
For this I am using the Messaging.SingleEmailMessage class.
I need to give users, the option to select email templates from a set of email templates in the Salesforce 'Email template'.
However i cannot find a way to preview emails which will be sent. My email templates will have data mapped from the respective record. How can i solve this problem of previewing the email templates with the values from email templates?
Please suggest.
Best Answer
In short, there is no simple 'preview' function available to you. You could work around it using Visualforce pages/components for the preview. Assuming you are using Visualforce Email Templates, you could do something like this:
<c:EmailContent obj="{!relatedTo}"/>
to render the contentIf you wanted to show your user a list of Email templates to choose from, you could simply query the EmailTemplate object with some valid criteria, e.g.