My Account | Internet Creations
Welcome, Guest.

Preserving comment spacing and line breaks in HTML emails (Visualforce and Custom)

Summary

Case Comments are text only fields and don't merge well in HTML email templates. When you try to merge a text field with special spacing and line breaks, they will be lost because HTML requires tags to accomplish such formatting.

Details

For example, you may have the following comment:
 
Step 1...
Step 2...
Step 3...
 
But when merged into an HTML template, the result may look like:
 
Step 1...Step 2...Step 3...

In an HTML/Custom template, you can use a basic CSS SPAN tag to preserve the "white-space" in your text-only merge field.  For example:
 
<span style="white-space:pre;"> 
{!relatedTo.E2CP__HistoryText__c}
</span>
 
For more information on this tag, visit http://www.w3schools.com/cssref/pr_text_white-space.asp
 
In a Visualforce template, you can use apex:outputField to preserve the "white-space" in your text-only merge field. For example:
 
<apex:outputField value="{!relatedTo.E2CP__Most_Recent_Public_Comment__c}"></apex:outputField>
 

Support

Open a Case