[英]C# Email - New lines not rendering with white-space: pre-wrap
I have an email with a table and one value contains a string with multiple lines. 我有一个带有表的电子邮件,一个值包含一个包含多行的字符串。 (enter-key) When viewed in outlook or view source in IE, the white-space is not working.
(enter-key)在IE中的outlook或view source中查看时,空格不起作用。
Any idea or any solution? 任何想法或任何解决方案?
Thanks. 谢谢。
This is related to Outlook (not C#). 这与Outlook(不是C#)有关。 I have the same problem (using Java to send mail).
我有同样的问题(使用Java发送邮件)。 I am using CSS style
white-space:pre-wrap;
我正在使用CSS样式的
white-space:pre-wrap;
on a span and it works well to preserve tabs, spaces, new lines and wrap text in GMail - web, Android and iOS. 在跨度上,它可以很好地保留GMail中的标签,空格,新行和换行文本 - 网络,Android和iOS。
As per my experimentation on Outlook 2016 Windows app and webapp (outlook.office365.com): 根据我在Outlook 2016 Windows应用程序和webapp(outlook.office365.com)上的实验:
New lines within html are not rendered as such. html中的新行不会这样呈现。 You need to add
<br>
tags at the end of each line to make sure that the email is rendered correctly with the new lines. 您需要在每行的末尾添加
<br>
标记,以确保使用新行正确呈现电子邮件。
You can do this within your c# code by replacing every new line character in your problematic value with <br>
. 您可以在c#代码中执行此操作,方法是使用
<br>
替换有问题值中的每个新行字符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.