Optimization for Outlook HTML

We’ve recently upgraded RT from the version in our old distro (3.8.7) to 4.2.10 (incidentally moving from Ubuntu 10.04 to 14.04).

First things first: Plain text messaging is flawless. Set $PreferRichText to 0 and use the plain text templates, everything just works. We were using plain text on the old install, and we’re ok with keeping it indefinitely.

We’re a small IT group within the University. The University became an Exchange shop a few years ago, so 90% of our clients are using Outlook 2010 or 2013. Set $PreferRichText to 1, enable the HTML templates, and the Outlook HTML becomes obvious by way of the extra blank lines in both the outgoing email messages and when viewing tickets through the web interface.

I’m well aware of the cause - Outlook uses paragraphs (

) instead of line breaks (
) when the user hits Enter. I’m aware of the multiple methods to correct for this on the client side; unfortunately, we’re not in a position to mandate how people compose email.

Has anyone been able to sanitize Outlook HTML to eliminate the extra whitespace? Either through RT itself or by manipulating the message via procmail prior to handing it to rt-mailgate?

$CheckMoreMSMailHeaders doesn’t help since the problem is in the HTML rather than the plain text. Likewise, I installed and tried all the HTML parsers (explicitly setting $HTMLFormatter) without success, presumably because that’s for converting HTML to plain.

I also tried installing HTML::Gumbo, just in case the HTML sanitization applied to more than just tables.

Thanks in advance for any tips for handling this!

Christopher Gilmore wrote on 4/27/2015 10:42 AM:

Has anyone been able to sanitize Outlook HTML to eliminate the extra whitespace? Either
through RT itself or by manipulating the message via procmail prior to handing it to
rt-mailgate?

Ok, I managed to do this the mostly-right way, but I’m curious to see if anyone has any tips for finishing the job. My lingering concern is that it’s a bit of a kludge - I’ve made a static style definition on the server for a setting that can be changed in Outlook and could potentially vary between multiple messages associated with the same ticket. Has anyone figured out a way to dynamically parse the style information from the email?

The good news is that my kludge will address the vast majority of my users, as it works with the default Outlook configuration. For reference, in case anyone else needs to sort this out:

I installed the Permissive HTML Mail extension, which (among other things) allows for style invocations to be passed from the message body to the ticket history.

I added a custom css file at /opt/rt4/local/static/css/msfix.css in order to set the MsoNormal style and enabled it in RT_SiteConfig.pm with @CSSFiles. I also modified all the HTML templates to include the style declaration. In both cases, I pulled the style information directly from the body of a sample message.

CSS file:

/* /opt/rt4/local/static/css/msfix.css /
p.MsoNormal, li.MsoNormal, div.MsoNormal
{
margin:0in;
margin-bottom:.0001pt;
}
/
end of /opt/rt4/local/static/css/msfix.css */

Template addition (before any HTML in the template, and quoted so as to not break Text::Template):

p.MsoNormal, li.MsoNormal, div.MsoNormal {q{{ margin:0in; margin-bottom:.0001pt; }}}

Hi Gilmore!
Could you specify where exactly you put style declaration for template.
I tried to add it just after “Content-Type: text/html” string, but it does
not work.
Thanks.On Wed, Apr 29, 2015 at 4:14 AM, Christopher Gilmore < c-gilmore@northwestern.edu> wrote:

Christopher Gilmore wrote on 4/27/2015 10:42 AM:

Has anyone been able to sanitize Outlook HTML to eliminate the extra
whitespace? Either
through RT itself or by manipulating the message via procmail prior to
handing it to
rt-mailgate?

Ok, I managed to do this the mostly-right way, but I’m curious to see if
anyone has any tips for finishing the job. My lingering concern is that
it’s a bit of a kludge - I’ve made a static style definition on the server
for a setting that can be changed in Outlook and could potentially vary
between multiple messages associated with the same ticket. Has anyone
figured out a way to dynamically parse the style information from the email?

The good news is that my kludge will address the vast majority of my
users, as it works with the default Outlook configuration. For reference,
in case anyone else needs to sort this out:

I installed the Permissive HTML Mail extension, which (among other things)
allows for style invocations to be passed from the message body to the
ticket history.

I added a custom css file at /opt/rt4/local/static/css/msfix.css in order
to set the MsoNormal style and enabled it in RT_SiteConfig.pm with
@CSSFiles. I also modified all the HTML templates to include the style
declaration. In both cases, I pulled the style information directly from
the body of a sample message.

CSS file:

/* /opt/rt4/local/static/css/msfix.css /
p.MsoNormal, li.MsoNormal, div.MsoNormal
{
margin:0in;
margin-bottom:.0001pt;
}
/
end of /opt/rt4/local/static/css/msfix.css */

Template addition (before any HTML in the template, and quoted so as to
not break Text::Template):

p.MsoNormal, li.MsoNormal, div.MsoNormal {q{{ margin:0in; margin-bottom:.0001pt; }}}

In the template, everything is considered part of the message headers until there’s a blank line. The style declaration should be immediately after that blank line. For example, my autoresponse template looks like:Subject: AutoReply: {$Ticket->Subject}
Content-Type: text/html

p.MsoNormal, li.MsoNormal, div.MsoNormal {q{{ margin:0in; margin-bottom:.0001pt; } }}

Greetings,

The same would apply to any other styles you wanted to use in the template.

From: rt-users [mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Vlad Shpolyanskiy
Sent: Wednesday, April 29, 2015 9:36 AM
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Optimization for Outlook HTML

Hi Gilmore!
Could you specify where exactly you put style declaration for template.
I tried to add it just after “Content-Type: text/html” string, but it does not work.
Thanks.

Hi, Christopher!
Thanks for the quick reply.
Put it after the blank line, but still no luck.
I’ve attached the example of email I’m getting as autoresponse.
My siteconfig option looks like:

Set( @CSSFiles, (‘msfix.css’) );

Probably I missed smth else :frowning:

29 апреля 2015 г., 17:42:40:

CG> In the template, everything is considered part of the message
CG> headers until there’s a blank line. The style declaration should
CG> be immediately after that blank line. For example, my autoresponse template looks like:

CG> Subject: AutoReply: {$Ticket->Subject}
CG> Content-Type: text/html

CG>
CG> p.MsoNormal, li.MsoNormal, div.MsoNormal
CG> {q{{
CG> margin:0in;
CG> margin-bottom:.0001pt;
CG> }
CG> }}
CG>
CG>

Greetings,

CG> The same would apply to any other styles you wanted to use in the template.

rt.html (1.48 KB)

Vlad:

FYI, the css file only applies to the web view. The messaging is handled entirely via the templates.

Looking at your test message, it seems that you have a different style being invoked, MsoPlainText. You should be able to find the style information by looking at the source code of the original message. You’ll need to define that style instead of/in addition to MsoNormal.

Good luck!
Chris-----Original Message-----
From: rt-users [mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Vlad V. Shpolyanskiy
Sent: Wednesday, April 29, 2015 10:09 AM
To: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Optimization for Outlook HTML

Hi, Christopher!
Thanks for the quick reply.
Put it after the blank line, but still no luck.
I’ve attached the example of email I’m getting as autoresponse.
My siteconfig option looks like:

Set( @CSSFiles, (‘msfix.css’) );

Probably I missed smth else :frowning:

29 апреля 2015 г., 17:42:40: