Developers and administrators can use Visualforce to create email templates. The advantage of using Visualforce over standard HTML email templates is that Visualforce gives you the ability to perform advanced operations on data that
is sent to a recipient.
Although
Visualforce email templates use standard
Visualforce components, they are not created in the same way.
Visualforce email templates always use components that are prefaced with the
messaging namespace. In addition:
- All Visualforce email templates must be contained within a single <messaging:emailTemplate> tag.
This is analogous to regular Visualforce pages being defined within a single <apex:page> tag.
- The <messaging:emailTemplate> tag must contain either a single <messaging:htmlEmailBody> tag or a single <messaging:plainTextEmailBody> tag.
- Several standard Visualforce components are not available for use within <messaging:emailTemplate>. These
include <apex:detail>, <apex:pageBlock> and all related pageBlock components, and all input
components such as <apex:form>. If you attempt to save a Visualforce email template with these components, an error message displays.
The following topics provide more details: