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
Liz MalmanLiz Malman 

Formatting a Merge Field in Visualforce Email Template

Hello all,

I'd like some help on how to change the formatting of one of my merge fields in my visualforce email template. The field I am merging is a text field but when the email is created, the formatting from the field does not carry over. 

For example...

Text in the Field looks like this: 
This is a test.
Please ignore this.

Text in the Email looks like this:
This is a test. Please ignore this. 

Does anyone have any idea how to carry over the format from the text field?

Thanks,
Liz
Raj VakatiRaj Vakati
You need to use the <br/> tag i guess and can you share the VF page code here ?? 
Liz MalmanLiz Malman
Here is the code. The field I want to maintain it's format is Event_Notes__c.

<h4>Event Info</h4>
<p>  
    <b>Event Name:</b> {!relatedTo.Name}<br/>
    <b>Event Date: </b> &nbsp; 
      <apex:outputText value="{0, date, short}">
          <apex:param value="{!relatedTo.Start_Date__c}"/>
      </apex:outputText> <br/>  
    <b>Start Time: </b> {!relatedTo.Event_Start_Time__c}<br/> 
    <b>Show Code: </b> &nbsp; {!relatedTo.SV_Show_Code__c}<br/>
    <b>Mobile Unit: </b> &nbsp; {!relatedTo.Mobile_Unit__c}<br/>
    <b>Venue: </b> &nbsp; {!relatedTo.Venue__r.Name}<br/>
    <b>Tech Manager: </b> &nbsp; {!relatedTo.Technical_Producer__c} - {!relatedTo.Technical_Producer_Phone_Number__c} <br/>
    <b>Producer:</b> &nbsp; {!relatedTo.Producer__c} <br/>
    <b>Director: </b> &nbsp; {!relatedTo.Director__c} <br/>
    <b>System: </b> &nbsp; {!relatedTo.SV_System__c} <br/>
    <b>Notes: </b> &nbsp; {!relatedTo.Event_Notes__c} <br/>
</p>
Raj VakatiRaj Vakati
I dnt see the message This is a test. Please ignore this in this email template 
Liz MalmanLiz Malman
That was an example of what the Event Notes field may be. So when the template grabs what is in that field, it changes the format of the field by putting everything on the same line. So I'm wondering what can be done on the visualforce side to maintain the format in which the field was filled out. 
Ajay K DubediAjay K Dubedi
Hi Liz,

Merge fields for Visualforce email templates use the same expression language as formulas:
{!Object_Name.Field_Name}
For example, you can start your email template with Hello, {!Contact.FirstName}. When you send the template, each recipient sees their first name in place of the merge field. If your recipient’s first name is John, he sees Hello, John! when he opens the email.


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
Liz MalmanLiz Malman
Hi Ajay,

Thank you for the response but that is not exactly what I'm looking for. I understand how merge fields work but I'm wondering if I can maintain the format of a text field in the emial template. When I merge the text field in the template, it changes the format. 

The picture below shows how the field was filled out.
How the field was filled out.

This next picture shows what the email template displays.
User-added image
Do you see how it does not space the text in the same way? I want it to maintain its original spacing.

 
Gulraiz MohammadGulraiz Mohammad
Hi Liz Malman, Could you pleae confirm if you are able to format "Notes" in email template, if yes then kindly help me as I am also stuck to format "Description" field in email template.Thanks!

Regards
Gulraiz