[SalesForce] Conditional formatting in HTML Email Templates

I need to display a message based on a condition which has to be formatted with bold style, add line breaks, etc. Using HTML markup inside IF condition is not working in HTML email templates.

For example,

{!IF(customObject.customField__c = 'Expected Value', '<BR><UL><LI>Item1</LI><LI>Item2</LI></UL>', '')}

However, the same IF condition works if the message to be displayed is plain text.

Do you have any suggestions on this?

Best Answer

For HTML template, use div and set the style display conditionally

<div style="display: {!IF(customObject.customField__c = 'Expected Value', '' , 'none')}">
<BR><UL><LI>Item1</LI><LI>Item2</LI></UL>
</div>

Alternative solution for visualforce email template

try with apex:ouptputpanel and use rendered attribute to show the content

<apex:outputpanel rendered="{!customObject.customField__c = 'Expected Value'}">
<BR><UL><LI>Item1</LI><LI>Item2</LI></UL>
</apex:outputpanel>