Skip to main content
Hey. I'm trying to include a line break into a custom label. This is all within a <messaging:htmlEmailBody>

!$Label.Test

Text 1

Text 2

returns: Text 1 Text 2

I've googled a tried a few options that don't really achieve any of this.

I've changed the label to

Text 1

<br></br>

Text 2

and modified the Visualforce to: 

<apex:outputLabel value="{!$Label.Test}" escape="false"/>

but it just returns Text 1 <br></br> Text 2

Any recommendations how to achieve this? Splitting this into two labels is kind of problematic. Thanks a lot in advance!
2 respuestas
  1. 22 may 2017, 13:02
    Hello tobiashagge, 

    It should be working just fine but as I don't have the whole view of your Email Template maybe there is something wrong with it. I'm sharing to you an example that I created so you can compare with yours.

     

    <messaging:emailTemplate recipientType="Contact"

    relatedToType="Account"

    subject="Case report for Account: {!relatedTo.name}"

    replyTo="support@acme.com">

    <messaging:htmlEmailBody >

    <html>

    <style type="text/css">

    body {font-family: Courier; size: 12pt;}

    table {

    border-width: 5px;

    border-spacing: 5px;

    border-style: dashed;

    border-color: ⌗FF0000;

    background-color: ⌗FFFFFF;

    }

    td {

    border-width: 1px;

    padding: 4px;

    border-style: solid;

    border-color: ⌗000000;

    background-color: ⌗FFEECC;

    }

    th {

    color: ⌗000000;

    border-width: 1px ;

    padding: 4px ;

    border-style: solid ;

    border-color: ⌗000000;

    background-color: ⌗FFFFF0;

    }

    </style>

    <body>

    <p>Dear {!recipient.name},</p>

    <p>Below is a list of cases related to {!relatedTo.name}.</p>

    <table border="0" >

    <tr>

    <th>Case Number</th><th>Origin</th>

    <th>Creator Email</th><th>Status</th>

    </tr>

    <apex:repeat var="cx" value="{!relatedTo.Cases}">

    <tr>

    <td><a href =

    "https://na1.salesforce.com/{!cx.id}">{!cx.CaseNumber}

    </a></td>

    <td>{!cx.Origin}</td>

    <td>{!cx.Contact.email}</td>

    <td> <apex:outputLabel value="{!$Label.Test_Line_Break}" escape="false"/></td>

    </tr>

    </apex:repeat>

    </table>

    <p/>

    <center>

    <apex:outputLink value="http://www.salesforce.com">

    For more detailed information login to Salesforce.com

    </apex:outputLink>

    </center>

    </body>

    </html>

    </messaging:htmlEmailBody>

    </messaging:emailTemplate>

    Label content:

    Text 1

    <br /><br />

    Text 2

    If you still having problems, please, share your template so we can take a look!

    ​Hope to have helped!

    Regards.

    Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
0/9000