function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BrandiTBrandiT 

Rich Text Area fields do not display correctly in Visualforce email template

I have an email template that I built as a visualforce template because I need it to show related list info. ..a functionality not available in text and html templates.  However, end users can't edit these and there is info that needs to change in each one.

So I created a Rich Text area field where users can change the template text on a couple sections.  But when I use the field in my template, the formatted text shows up as a block of text with HTML format tags mixed in. 

 

Ex.  "EXAMPLE TEXT IN FIELD (please see below)"

Shows up as

"<b><u>EXAMPLE TEXT IN FIELD</ul></b> <font color=red>(please see below)</font>"

 

Is there anyway to keep the formatted text and have it show up correctly in the Visualforce template?

The formatting in this field is required because it's going to outside clients.  Parts of the field are formatted differently which is why I'm trying to use the Rich Text Area field in the first place.

Please help!!

Best Answer chosen by Admin (Salesforce Developers) 
WesNolte__cWesNolte__c

Hey

 

Are you using an outputText field? You'll need to set 'escape=false', but also be aware that getting an email template to look the same when viewed from different clients e.g. Yahoo, Gmail, Outlook etc is very difficult. In fact there are companies that make a living out of it e.g. http://mailchimp.com.

 

Wes

All Answers

WesNolte__cWesNolte__c

Hey

 

Are you using an outputText field? You'll need to set 'escape=false', but also be aware that getting an email template to look the same when viewed from different clients e.g. Yahoo, Gmail, Outlook etc is very difficult. In fact there are companies that make a living out of it e.g. http://mailchimp.com.

 

Wes

This was selected as the best answer
BrandiTBrandiT

OH That worked perfectly!  I can't believe it was something so simple.

 

Thank you VERY VERY MUCH  :-)

fgwarb_devfgwarb_dev

I'm having this problem inside salesforce itself.  Our users enter formatted data into the RTA, click save, and the markup is displayed.

 

Do you have any idea what is going on?

 

I've reproduced it, but can't document the steps as I haven't figured out what exactly it was that tripped it...

Force.com discussion forumForce.com discussion forum

hi All,

I have rich text field and i want to display the that field data in visaul force page.

i used  <apex:outputText style="font-size:11px;" value="{!descr.Description_Language__c}:" escape="false"/> to display the RTF data but still it is displaying the RTF data on UI like '<span><p> this is desc. </p> </Span>' instead of 'this is desc.'

 

can any one please tell me the resolution , is it possible to do this in visual force/apex or if there are any other workaround which will remove these html tag either by using the java script tag or any other way. 

rob3000rob3000

I'm having similar problems with displaying a rich text field in an visualforce template. My code looks like this:

 

<messaging:emailTemplate recipientType="Contact" 
relatedToType="Visit_Report__c"
subject="Visit Report for: {!relatedTo.Account__c}">
<messaging:plainTextEmailBody >

<apex:outputText escape="false" value="{!relatedTo.Visit_Result__c}" />

</messaging:plainTextEmailBody>
</messaging:emailTemplate>

 

Visit_Result__c is a rich text field and people usually write their reports in word or excel and then paste it into this field and distribute it with an email template.

 

However, if I run a test with my little template it looks something like this:

 

<p><strong><span class="titleSeparatingColon"><font size="2">Visit Results:<br></font></span></strong><span class="titleSeparatingColon"><font size="2">1) Participants<span class="titleSeparatingColon">.... and so on.

 

 

prathibha s 3prathibha s 3
Hi Wes,

I have tried your answer with my case, I want to display Text Area field value in a VF Email Template,
GoToMeeting Details: <apex:outputText value="{!relatedTo.Requested_Actitivity__r.GoToMeeting_Details__c}" escape="false"/>
But still I can see the entire field content displayed in single line. Am I missing anything here? Please help!

Thanks,
Prathibha