You need to sign in to do that
Don't have an account?
Michael_Mantouvalos
Visualforce Email template is not rendering and it shows Html Tags when email is being sent
Hello everyone,
I have created a visualforce Email template that uses a visualforce component to display some records in a form of a table. The problem is that inside my visualforce component whatever HTML I use, it does not render the HTML and in Email preview, it shows the HTML tags. For example I want to create a simple table isnide my component :
Email Template :
<messaging:emailTemplate subject="test subject" recipientType="Contact" relatedToType="Booking__c">
<messaging:plainTextEmailBody >
<c:PaxInformation/>
Congratulations!
This is your new Visualforce Email Template.
Dear Partner,
blah blah blah.......
</messaging:plainTextEmailBody>
</messaging:emailTemplate>
Visualforce Component (Name : PaxInformation)
<apex:component controller = "PaxInformationController" access="global" >
<table class="table">
<thead>
<tr>
<th>Opportunity Name</th>
<th>Opportunity Description</th>
<th>Opportunity Amount</th>
</tr>
</thead>
</table>
</apex:component>
Final Email received (body):
____________________________________
Any ideas on why is this happening?
Why it does not render the html tags to an actual html table?
Thanks in advance,
Michael.
I have created a visualforce Email template that uses a visualforce component to display some records in a form of a table. The problem is that inside my visualforce component whatever HTML I use, it does not render the HTML and in Email preview, it shows the HTML tags. For example I want to create a simple table isnide my component :
Email Template :
<messaging:emailTemplate subject="test subject" recipientType="Contact" relatedToType="Booking__c">
<messaging:plainTextEmailBody >
<c:PaxInformation/>
Congratulations!
This is your new Visualforce Email Template.
Dear Partner,
blah blah blah.......
</messaging:plainTextEmailBody>
</messaging:emailTemplate>
Visualforce Component (Name : PaxInformation)
<apex:component controller = "PaxInformationController" access="global" >
<table class="table">
<thead>
<tr>
<th>Opportunity Name</th>
<th>Opportunity Description</th>
<th>Opportunity Amount</th>
</tr>
</thead>
</table>
</apex:component>
Final Email received (body):
____________________________________
Any ideas on why is this happening?
Why it does not render the html tags to an actual html table?
Thanks in advance,
Michael.
I was able to figure this out. You need to use
<messaging:htmlEmailBody> instead of <messaging:plainTextEmailBody> tag.
Try this code:
If this information helps, please mark the answer as best.Thank you
All Answers
Does this happen only in Outlook or across other email clients like Gmail/yahoo etc too? Thanks
It doesn't have to do with outlook or Gmail etc.. it has to do with salesforce. because in the preview of my email template I also get the unrenderd html table. For my test I used Gmail client
Make sure to use below formatting in your component.
Thanks.
Ashvin
Hi Ashvin ,
Thanks for the reply!
Unfortunately this did not made any difference.
The email I get now is :
I was able to figure this out. You need to use
<messaging:htmlEmailBody> instead of <messaging:plainTextEmailBody> tag.
Try this code:
If this information helps, please mark the answer as best.Thank you