Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to create a conditional email template that will show fields based off ticked checkboxes. In the statements, I would like to include a link in standard HTML format Sample Text but the output isnt what I'm looking for.

Here is an example of my code:

<messaging:emailTemplate subject="Quote Request Update" recipientType="User" relatedToType="Account">
<messaging:htmlEmailBody >

Hello {!},

<br/><br/>Example {!if(relatedTo.sample__c = true,'<a href="">Google</a>','Value if False')}


The output will show the message but will display the "a tag" code instead of displaying the way normal HTML coding would result in. I'm pretty new to VF, trying to hack my way through this. Any help is appreciated.

share|improve this question
up vote 5 down vote accepted

Visualforce tries really hard to not allow potential security issues. One of the things that is included in this is not allowing HTML to be inserted from merge fields, unless it's part of an <apex:outputPanel escape="false"> element.

Really though a better solution would be to use conditionally rendered elements here. Something like:


<apex:outputLink rendered="{!relatedTo.sample__c = true}" value="">
<apex:outputText rendered="{!relatedTo.sample__c != true}">Value if False<apex:outputText>

The rendered attribute controls if the element is displayed or not, and since they have mutually exclusive values only one of the two will ever be rendered.

share|improve this answer
Works perfect, thanks for your help! – sfdcJameson Mar 24 '14 at 16:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.