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
AndyPandyAndyPandy 

Text Email Template Formatting HAVOC!!

Hi All,

 

Slightly dramatic subject, but my issue seems ridiculous.

 

I have created a very basic Text Email Template, to use in conjunction with a Workflow Rule.  Everything works perfectly, with the exception of the formatting of the last 4 rows of the Email.

 

See Email Template Body below:

 

Dear Rental Team,

Please find details of a new Rental booking from {!Rentals__c.CreatedBy}:

Link to booking form:  {!Rentals__c.Link}

Hospital:  {!Rentals__c.Hospital__c}
Surgeon:  {!Rentals__c.Surgeon__c}
PO Number:  {!Rentals__c.PO_Number__c}

Arrival Date:  {!Rentals__c.Arrival_Date__c}
Delivery Time:  {!Rentals__c.Delivery_Time__c}
Delivery Department:  {!Rentals__c.Delivery_Department__c}
Collection Date:  {!Rentals__c.Collection_Date__c}
Contact Person:  {!Rentals__c.Contact_Person__c}
Contact Telephone No.:  {!Rentals__c.Contact_Telephone_No__c}

Tray 1:  {!Rentals__c.Tray_1_Quantity__c} x {!Rentals__c.Tray_1__c}
Tray 2:  {!Rentals__c.Tray_2_Quantity__c} x {!Rentals__c.Tray_2__c}
Tray 3:  {!Rentals__c.Tray_3_Quantity__c} x {!Rentals__c.Tray_3__c}
Tray 4:  {!Rentals__c.Tray_4_Quantity__c} x {!Rentals__c.Tray_4__c}

When I format it like this, the last 4 rows, in the email received (Outlook 2010), appear as one line, e.g.:

 

Tray 1:  2 x Kit A Tray 2:  1 x Kit B Tray 3:  1 x Kit C Tray 4:  2 x Kit D

 

Which does not appear to make sense.  However, as it was doing this, I adjusted the Email Body (just the last 4 rows), to look like the following:

 

Tray 1:  {!Rentals__c.Tray_1_Quantity__c} x {!Rentals__c.Tray_1__c}

Tray 2:  {!Rentals__c.Tray_2_Quantity__c} x {!Rentals__c.Tray_2__c}

Tray 3:  {!Rentals__c.Tray_3_Quantity__c} x {!Rentals__c.Tray_3__c}

Tray 4:  {!Rentals__c.Tray_4_Quantity__c} x {!Rentals__c.Tray_4__c}

This however, formats the email on separate rows, but with a blank row in between (i.e. double-spaced), e.g.:

 

Tray 1:  2 x Kit A

 

Tray 2:  1 x Kit B

 

Tray 3:  1 x Kit C

 

Tray 4:  2 x Kit D

 

Can anyone help me to format this as I would like, with each Tray shown on a separate row, but with no blank row in between, e.g.:

 

Tray 1:  2 x Kit A

Tray 2:  1 x Kit B

Tray 3:  1 x Kit C

Tray 4:  2 x Kit D

 

What am I doing wrong?

 

Many thanks,

 

Andy

Best Answer chosen by Admin (Salesforce Developers) 
SabrentSabrent

I have included a letter head here too. You can delete the <img src....> if you don't want the letter head. To change to your letter head replace the file = xxxYY1234YY with your file id. You can also change the border of the table (refere: w3schools.com). If you need more blank lines add the <br/>. Hope this helps. let me know how you go.

 

<html>
<body>

<img src="https://c.na9.content.force.com/servlet/servlet.FileDownload?file=xxxYY1234YY" height="90" width="600"/>
</a>

<br/>
<br/>

Dear Rental Team, <br/> <br/>

Please find details of a new Rental booking from: {!Rentals__c.CreatedBy} <br/>

Link to booking form:  {!Rentals__c.Link} <br/>

<h4>Three rows and two columns:</h4>
<table border="1">
<tr>
  <td>Arrival Date</td>
  <td>{!Rentals__c.Arrival_Date__c} </td>
 </tr>

<tr>
  <td>Delivery Time</td>
  <td> {!Rentals__c.Delivery_Time__c}</td>
 </tr>

<tr>
  <td>Delivery Department</td>
  <td> {!Rentals__c.Delivery_Department__c}</td>
 </tr>

</table>  <br/>

Regards, <br/>

GJHTYT 

</body>
</html>

 

 

 

 

All Answers

SamuelDeRyckeSamuelDeRycke

Just a guess really, but have you tried adding  \n  ?

SabrentSabrent

My proposed solution is also a bit dramatic, but it may work.

Try this, at the end of the line-  

Tray 1:  {!Rentals__c.Tray_1_Quantity__c} x {!Rentals__c.Tray_1__c}

Keep hitting Delete button on the keyboard until the next line jumps to the previos line and then hit enter. Do this for all 4 lines.

Also,Is there a reason why you are using Text email template? You can have more flexibility with HTML or Custom email template.Text Email Templates provide very little or no Customisation or visual elements.

AndyPandyAndyPandy

Hi rov,

 

Thanks for getting back to me - much appreciated.

 

I've had a go at all sorts of things like your suggestion (as well as the actual suggestion you gave), tinkering with the potential differences between Enter and Return as well - but the issue still persists.

 

My reasoning for not using an HTML template is my complete lack of HTML knowledge.  Given my requirement (a fairly simple Email Template displaying the various fields from a Custom Object record), could you help me out at all?

 

Maybe some sample HTML for a tabular design, so instead of my Text version showing "Hospital: [Hospital Name]" - it could be a table with one column being the field name, and the second column being the field content.

 

Any help you could provide would be gratefully recived.

 

Many thanks,

 

Andy

SabrentSabrent

I have included a letter head here too. You can delete the <img src....> if you don't want the letter head. To change to your letter head replace the file = xxxYY1234YY with your file id. You can also change the border of the table (refere: w3schools.com). If you need more blank lines add the <br/>. Hope this helps. let me know how you go.

 

<html>
<body>

<img src="https://c.na9.content.force.com/servlet/servlet.FileDownload?file=xxxYY1234YY" height="90" width="600"/>
</a>

<br/>
<br/>

Dear Rental Team, <br/> <br/>

Please find details of a new Rental booking from: {!Rentals__c.CreatedBy} <br/>

Link to booking form:  {!Rentals__c.Link} <br/>

<h4>Three rows and two columns:</h4>
<table border="1">
<tr>
  <td>Arrival Date</td>
  <td>{!Rentals__c.Arrival_Date__c} </td>
 </tr>

<tr>
  <td>Delivery Time</td>
  <td> {!Rentals__c.Delivery_Time__c}</td>
 </tr>

<tr>
  <td>Delivery Department</td>
  <td> {!Rentals__c.Delivery_Department__c}</td>
 </tr>

</table>  <br/>

Regards, <br/>

GJHTYT 

</body>
</html>

 

 

 

 

This was selected as the best answer
SabrentSabrent

oopos!! forgot to mention above that this is a custom email template. so when you create a new template, choose Custom (without Letterhead).

AndyPandyAndyPandy

rov!

 

Apologies for the late reply, but your solution is marvellous, thank you!  I've extrapolated it out to include all the fields I want - see below - but was hoping for just a tiny bit of extra help - if that's ok?

 

Can you help me to learn how I can:

1) Change all the font to Arial size 10

2) Fix the widths of each column in the tables?

 

Thank you so much again!

 

Andy

 

<html>
<body>

Dear Rental Team, <br/> <br/>

Please find details of a new Rental booking from: {!Rentals__c.CreatedBy} <br/> <br/>

Link to booking form:  {!Rentals__c.Link} <br/> <br/>

<table border="1">

<tr>
  <td>Hospital</td>
  <td>{!Rentals__c.Hospital__c}</td>
 </tr>

<tr>
  <td>Surgeon</td>
  <td>{!Rentals__c.Surgeon__c}</td>
 </tr>

<tr>
  <td>PO Number</td>
  <td>{!Rentals__c.PO_Number__c}</td>
 </tr>

</table>  <br/> <br/>

<table border="1">

<tr>
  <td>Arrival Date</td>
  <td>{!Rentals__c.Arrival_Date__c} </td>
 </tr>

<tr>
  <td>Delivery Time</td>
  <td> {!Rentals__c.Delivery_Time__c}</td>
 </tr>

<tr>
  <td>Delivery Department</td>
  <td> {!Rentals__c.Delivery_Department__c}</td>
 </tr>

<tr>
  <td>Collection Date</td>
  <td>{!Rentals__c.Collection_Date__c}</td>
 </tr>

<tr>
  <td>Contact Person</td>
  <td>{!Rentals__c.Contact_Person__c}</td>
 </tr>

<tr>
  <td>Contact Telephone No.</td>
  <td>{!Rentals__c.Contact_Telephone_No__c}</td>
 </tr>

</table>  <br/> </br>

<table border="1">

<tr>
  <td>Tray 1</td>
  <td>{!Rentals__c.Tray_1_Quantity__c} x {!Rentals__c.Tray_1_Quantity__c}</td>
 </tr>

<tr>
  <td>Tray 2</td>
  <td>{!Rentals__c.Tray_2_Quantity__c} x {!Rentals__c.Tray_2_Quantity__c}</td>
 </tr>

<tr>
  <td>Tray 3</td>
  <td>{!Rentals__c.Tray_3_Quantity__c} x {!Rentals__c.Tray_3_Quantity__c}</td>
 </tr>

<tr>
  <td>Tray 4</td>
  <td>{!Rentals__c.Tray_4_Quantity__c} x {!Rentals__c.Tray_4_Quantity__c}</td>
 </tr>

</table>  <br/> <br/>

</body>
</html>

 

SabrentSabrent

Glad it worked for you. 

 

For the font style, you can either set it for each row or set it only once like I have done here -

 

<html>

<head>

<STYLE TYPE="text/css">

TD{font-family: Arial; font-size: 12pt; width:1%;}

</STYLE>

</head>

<body>

Dear Rental Team, <br/> <br/>

.

.

.

.

</body>

</html>

 

For the column width, see an example here

http://www.w3schools.com/tags/att_col_width.asp

 

Feel free to ask for help. (when done, can you please mark it solved ?)

 

 

 

 

 

 

 

 

 

 

AndyPandyAndyPandy

Thanks again rov - everything seems to be working now!

 

Appreciate all your help - keep up the excellent work.

 

Andy