+ Start a Discussion
JimPDXJimPDX 

Merging custom HTML text with HTML email templates

Hello. We are using a Visualforce page to store HTML in a field called "Email_Text__c" using this:

 

 

<apex:inputTextarea value="{!Lead.Email_Text__c}" richText="true" cols="40" rows="8"/>

 

 In my email template I insert this value as follows:

 

 

<body><p class="style11">{!Lead.Email_Text__c}</p>

 

When we send an email and select the template containing this value we see the escaped HTML in the body of the email itself. Can anyone think of ways to address this? It is important that our users be able to leverage the embedded wysiwyg editor on the field itself.

 

 

Dear Frank,Hello there. Nice <strong>meeting</strong> you.<br /> <br /> I would like to discuss X, Y and Z. Let's get together <em>soon</em>.<br type="_moz" />

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

Escaping is an automatic feature designed to prevent cross-scripting issues. But, you can override it by telling Salesforce's technology that you're aware that there might be HTML code. You can do this by using the outputText tag:

 

 

<apex:outputText escape="false" value="{!Lead.Email_Text__c}"/>

This informs Visualforce that you'd like to display whatever HTML code might be in your field verbatim without escaping the code (i.e. < becomes &lt; if escape="true", which is the default).

 

All Answers

sfdcfoxsfdcfox

Escaping is an automatic feature designed to prevent cross-scripting issues. But, you can override it by telling Salesforce's technology that you're aware that there might be HTML code. You can do this by using the outputText tag:

 

 

<apex:outputText escape="false" value="{!Lead.Email_Text__c}"/>

This informs Visualforce that you'd like to display whatever HTML code might be in your field verbatim without escaping the code (i.e. < becomes &lt; if escape="true", which is the default).

 

This was selected as the best answer
JimPDXJimPDX

Thanks! I knew about that and forgot, having built an entire site with Sites and storing HTML in custom objects. Thanks for the reminder...

 

-Jim 

JimPDXJimPDX

sfdcfox wrote:

Escaping is an automatic feature designed to prevent cross-scripting issues. But, you can override it by telling Salesforce's technology that you're aware that there might be HTML code. You can do this by using the outputText tag:

 

This informs Visualforce that you'd like to display whatever HTML code might be in your field verbatim without escaping the code (i.e. < becomes &lt; if escape="true", which is the default).

 


Unfortunately this can not be used in HTML email templates. Without changing our library of templates to Visualforce, is there a way to NOT escape HTML that is linked within an HTML email template? 

 

sfdcfoxsfdcfox
The "standard HTML" editor will automatically translate HTML into it's escaped form, but the "custom HTML" editor won't (at least, it used to be this way for the longest time). I'd have to confirm that. Either way, I think the net result is that you will need to change your templates to a new format if you'd like to be able to include HTML code as a raw field.