在纯文本电子邮件中插入换行符

时间:2012-11-02 06:57:29

标签: xml aviarc

我需要发送电子邮件。我遍历数据集以获取电子邮件正文中包含的电子邮件地址和其他信息。

我更喜欢电子邮件是纯文本。我的问题是我无法弄清楚如何插入换行符,以便以清晰的方式布置信息。

我试过这个:

<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}"/>  

换行变量设置为&amp; #10; &安培; #13; (显示空格,以便在此处显示)

这不起作用。电子邮件只是一个连续行中所有正文值标记的串联。

我还尝试将电子邮件输出为html并使用字符“&lt; br&gt;” (在hash,&符号,ascii char格式中)用于换行变量。这是一次失败。

我无法在doco中找到任何东西。

我是否需要创建一个txt格式的JasperReport来附加到电子邮件中,或者是否有办法在电子邮件正文中插入换行符和/或标记字符?

1 个答案:

答案 0 :(得分:2)

尝试只使用一个正文标记。 <{1}}或字符串中的实际新行都应该有效。

&#10;

另见答案:https://stackoverflow.com/a/2012277/1164143。建议最好(即最正确或最便携)的方法是使用普通/文字新行。但是编码的新行(<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. ---------------------------------------------------------------"/> &#10;)在Aviarc中运行良好。