2

I need to send out emails. I iterate through a dataset to obtain the email addresses and other information which is included in the email body.

I prefer the emails to be plain text. My issue is that I can't figure out how to insert line feeds, so that the information is laid out in a legible manner.

I have tried this:

<email-to address="{$overdue_releases.req_email}"/>

<subject value="OVERDUE ITEMS NOTIFICATION"/>

<body value="This is a notification that you have the following overdue items:{$var.newline}"/>
<body value="-----------------------------------------------------------------{$var.newline}"/>
<body value="{$var.newline}"/>
<body value="Borrower: {$overdue_releases.req_name}{$var.newline}"/>
<body value="Phone: {$overdue_releases.req_phone}{$var.newline}"/>
<body value="Equipment item: {$overdue_releases.eqm_name} - {$overdue_releases.itm_identification}{$var.newline}"/> 
<body value="Date borrowed: {$overdue_releases.rel_date_pickedup}{$var.newline}"/>  
<body value="-----------------------------------------------------------------{$var.newline}"/>  
<body value="Please return the overdue item(s) as AS SOON AS POSSIBLE.{$var.newline}"/>  
<body value="-----------------------------------------------------------------{$var.newline}"/>  

The newline variable was set as & # 10 ; & # 13; (show with spaces so it will display here)

This is not working. The email is simply a concatenation of all the body value tags in one continuous line.

I have also tried to output the email as html and use the characters "<br>" (in hash, ampersand, ascii char format) for the newline variable. This was a failure.

I have not been able to find anything in the doco.

Will I need to resort to creating a txt format JasperReport to attach to an email, or is there a way to insert linefeed and/or markup characters in the email body?

fenix
  • 68
  • 1
  • 7
  • It would be great if you could update the title to reflect your actual question, seeing as your question is about inserting line breaks in plain text emails and not about creating emails. Cheers! – Adam Sharp Nov 02 '12 at 20:33

1 Answers1

2

Try using just a single body tag. Either &#10; or just actual new lines in the string should work.

<body value="This is a notification that you have the following overdue items:
-----------------------------------------------------------------

Borrower: {$overdue_releases.req_name}
Phone: {$overdue_releases.req_phone}
Equipment item: {$overdue_releases.eqm_name} - {$overdue_releases.itm_identification}
Date borrowed: {$overdue_releases.rel_date_pickedup}
-----------------------------------------------------------------
Please return the overdue item(s) as AS SOON AS POSSIBLE.
---------------------------------------------------------------"/>

See also this answer: https://stackoverflow.com/a/2012277/1164143. It is suggested that the best (i.e., most correct or most portable) method is to use plain/literal new lines. However encoded new lines (&#10;, &#10;&#13;) work fine in Aviarc.

Community
  • 1
  • 1
Adam Sharp
  • 3,618
  • 25
  • 29