简体   繁体   中英

Why does Outlook 2010 break my HTML email body?

Whenever I send a HTML email from my own server (with my own emailer code) to Outlook 2010, it strips out the first 2 characters of every single HTML attribute.

Here's a snippet from the HTML body (see the table attributes are screwed up):

<table cellpadding=" cellspacing=" border=" class=ostdata">  
<thead>                               
<tr>                                       
<th>Field</th>                                 
<th>Value</th>                               
</tr>     
</thead>
<tr>                
<th>Test</th>  
<td>Hello world!</td>
</tr>
</table>

The full HTML body from Outlook 2010:

<style> BODY     {font-family:Arial,Helvetica,Tahoma,sans-serif;font-size:12px;font-weight:normal;color:#4F4F4F;margin:8px;padding:0}      H1                           {font-size:14px;font-weight:bold;margin-top:18px} .postdata                                                                                             {margin:10px;padding:10px 0} .postdata TABLE                                  {font-family:Arial,Helvetica,Tahoma,sans-serif;font-size:12px;font-weight:normal;color:#4F4F4F}            .postdata TH                                                           {font-weight:bold;color:#FFF;text-align:left;padding:4px 8px;background-color:#555}                .postdata TD                                                      {padding:4px 8px}           .postdata THEAD TH        {font-size:0.85em;font-weight:normal;text-transform:uppercase;background-color:#444} .signature                                                                     {color:#9F9F9F;margin:40px 0 10px 0}</style>Test email with single <table style=olor: red" width=00%"><tr><td>Table data</td></tr></table><table cellpadding=" cellspacing=" border=" class=ostdata">  <thead>                               <tr>                                       <th>Field</th>                                 <th>Value</th>                               </tr>     </thead><tr>                <th>Test</th>  <td>Hello world!</td></tr></table>

The header from Outlook 2010 (I can't view the entire source in Outlook 2010):

Return-Path: <REMOVED>
Delivered-To: REMOVED
Received: (qmail 31757 invoked by alias); 22 Oct 2014 02:50:45 -0000
Delivered-To: alias-localdelivery-REMOVED
Received: (qmail 31751 invoked by uid 102); 22 Oct 2014 02:50:45 -0000
Date: 22 Oct 2014 02:50:45 -0000
Message-ID: <20141022025045.31750.REMOVED>
To: REMOVED
Subject:
From: REMOVED
X-Mailer: MailBot version 1.24
MIME-Version: 1.0
Content-Type: multipart/alternative;
                boundary="MailBot=="

The full HTML email when opened with Mac Mail 7.3:

Return-Path: <REMOVED>
Delivered-To: REMOVED
Received: (qmail 32582 invoked by alias); 22 Oct 2014 02:57:39 -0000
Delivered-To: alias-localdelivery-REMOVED
Received: (qmail 32579 invoked by uid 102); 22 Oct 2014 02:57:39 -0000
Date: 22 Oct 2014 02:57:39 -0000
Message-ID: <20141022025739.32578.REMOVED>
To: REMOVED
Subject: 
From: REMOVED
X-Mailer: MailBot version 1.24
MIME-Version: 1.0
Content-Type: multipart/alternative;
    boundary="MailBot=="

This is a multipart message in MIME format.

--MailBot==
Content-Type: text/plain;
    charset="us-ascii"
Content-Transfer-Encoding: 7bit

Test email with single

--MailBot==
Content-Type: text/html;
    charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<style> BODY    {font-family:Arial,Helvetica,Tahoma,sans-serif;font-size:12px;font-weight:normal;color:#4F4F4F;margin:8px;padding:0}    H1      {font-size:14px;font-weight:bold;margin-top:18px} .postdata                     {margin:10px;padding:10px 0} .postdata TABLE            {font-family:Arial,Helvetica,Tahoma,sans-serif;font-size:12px;font-weight:normal;color:#4F4F4F} .postdata TH                {font-weight:bold;color:#FFF;text-align:left;padding:4px 8px;background-color:#555} .postdata TD                {padding:4px 8px}   .postdata THEAD TH  {font-size:0.85em;font-weight:normal;text-transform:uppercase;background-color:#444} .signature                 {color:#9F9F9F;margin:40px 0 10px 0}</style>Test email with single <table style="color: red" width="100%"><tr><td>Table data</td></tr></table><table cellpadding="0" cellspacing="1" border="0" class="postdata">   <thead>     <tr>            <th>Field</th>          <th>Value</th>      </tr>   </thead><tr>    <th>Test</th>   <td>Hello world!</td></tr></table>

--MailBot==--

Why is Outlook doing this?

The symptoms are consistent with declaring Content-Transfer-Encoding: quoted-printable but then not actually using this encoding, and the headers you posted seem to bear this out.

In QP, you would have attribute=3D"value" because the equals sign is a metacharacter in this encoding, and needs to be encoded as =3D . It is fathomable (though arguably not entirely correct) that a sequence of an equals sign followed by two non-hex (and non-newline) characters is discarded by Outlook as illegal.

In any event, I would blame your sending code -- which you are not showing --, not Outlook (even though I personally believe Outlook should be banned for other reasons).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM