white-space: pre-line alternative for Outlook

Viewed 3995

I have to wrap some email text content in a <pre> tag so that the formatting keeps the line breaks but collapses unnecessary spaces.

What I need is exactly the following:

<pre style="white-space: pre-line">Text here</pre>

This works perfectly on the browser BUT, pre-line is not supported by outlook. That means, that I have to use 'pre-wrap' which respects the line breaks but keeps some really big unwanted spaces, which the client does not want.

I can't edit the content of the text (like adding a </br>), as it is generated by an external system, which does not allow any editing...

I also tried the following:

white-space: normal;
white-space: nowrap;
white-space: pre;
white-space: pre-wrap;
white-space: break-spaces;

I also tried to use a div, instead of a <pre> tag, and also the <xmp> tag with white-space: pre-wrap and pre-line, <wbr> tag with same settings, but nothing gave me the expected results.

This is the code, which I insert into the external system:

<pre style="white-space: pre-line"><&MEETING_INFO></pre>

The code runs through an external system which generates the complete text which I cannot access. This is an example of a full code, including text after it is generated by the external system and sent to Outlook:

<pre style="white-space: pre-line">
    Beginn:      27.05.2019 10:00 US/Eastern
    Ende:        27.05.2019 11:00 US/Eastern
    Kursleiter: Mustermann, Max
    Einrichtung:   Building A
    Veranstaltungsraum:   BC 33 - Raum 3.07 - Berlin
</pre>

Actual results as displayed in Outlook:

<pre style="white-space: pre-line">
    Beginn: 27.05.2019 10:00 US/Eastern Ende: 27.05.2019 11:00 US/Eastern
    Kursleiter: Mustermann, Max Einrichtung: Building A Veranstaltungsraum: BC 33 - Raum 3.07 - Berlin
</pre>

How it should be:

<pre style="white-space: pre-line">
    Beginn: 27.05.2019 10:00 US/Eastern
    Ende: 27.05.2019 11:00 US/Eastern
    Kursleiter: Mustermann, Max
    Einrichtung: Building A
    Veranstaltungsraum: BC 33 - Raum 3.07 - Berlin
</pre>

I tried everything and I'm desperate. Is there ANY alternative?? Many thanks for any help!

2 Answers

Outlooks doesn't like most code so a walk around would be to simulate the code for pre. Below is an example of how you can do it

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tbody>
    <tr>
      <td style="font-family: monospace;font-size:13px;color:#000001;">
 Beginn: 27.05.2019 10:00 US/Eastern<br>
    Ende: 27.05.2019 11:00 US/Eastern<br>
    Kursleiter: Mustermann, Max<br>
    Einrichtung: Building A<br>
    Veranstaltungsraum: BC 33 - Raum 3.07 - Berlin
  </td>
    </tr>
  </tbody>
</table>

Rest of you HTML can go around it.

outlook remove unnecessary white spaces....instead of using any CSS property you can replace newline with <br> tag in your velocity mail template..

In your case it would be:

$MEETING_INFO.replaceAll( "\r?\n","<br/>")

Related