换行符显示在屏幕上,但不显示在电子邮件中 [英] Newline showing up on screen but not in email

查看:164
本文介绍了换行符显示在屏幕上,但不显示在电子邮件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表(错误),我打印到屏幕并发送电子邮件正文。但是首先我用一个换行符分隔列表的元素:

 \\\
.join(errors)

然后我将其打印到控制台并作为电子邮件发送。在控制台上,它显示为换行符:

 生成报告错误
另一个错误

然而,在电子邮件中,他们无法显示...

 错误生成报告另一个错误

发生了什么?



编辑:



为了进一步使事情复杂化,我刚刚注意到发送了 2 电子邮件,一个其中显示换行符,而其中一个不显示。

  sendEmail(SUPPORT_EMAIL_ADDRESS,应用程序意外终止,\ 
脚本将退出.\\\
\\\
Error消息:\\\
%s%\
\\\
.join(errors))
sendEmail(USERS_EMAIL_ADDRESS, 报告延迟,
\\\
.join(errors),
html,[],[],SUPPORT_EMAIL_ADDRESS)
/ pre>

第一个有它们,而第二个没有吨。这是因为html格式化在第二个...?

解决方案

如果您的电子邮件是HTML格式,那将影响演示的新行。


I have a list (errors) that I both print to the screen and send in the body of an email. But first I separate the elements of the list with a newline character:

"\n".join(errors)

I then print it to the console and send it as an email. On the console it appears delimited by newlines:

Error generating report
Another error

In the email, however, they fail to show...

Error generating report Another error

What's going on?

Edit:

To further complicate things, I just noticed that 2 emails are sent, one of which displays the newline and one of which doesn't!

sendEmail(SUPPORT_EMAIL_ADDRESS, "application terminated unexpectedly.", \
                   "The script will exit.\n\nError Message:\n%s" % \
                   "\n".join(errors))
sendEmail(USERS_EMAIL_ADDRESS, "report is delayed.", 
                   "\n".join(errors), 
                   "html", [], [], SUPPORT_EMAIL_ADDRESS)

The first does have them while the second doesn't. Is this because of the html formatting in the second...?

解决方案

If your email is HTML formatted then that would affect presentation of newlines.

这篇关于换行符显示在屏幕上,但不显示在电子邮件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆