Subjects appearing "garbled" or "corrupted" when they are encoded

We recently ran into an issue where subjects from external sources might appear to be garbled when using Exchange Server 2007 and the solution we found required a bit of digging.

Per RFC 2047, encoded words can be used within the subject headers of a message and indeed Exchange Server 2007 is no exception and does support this. In a MIME message an encoded subject may look something like this:

 Subject: =?ISO-8859-1?B?VGhpcyBpcyBhIHRlc3Q=?=

The first part, ISO-8859-1, indicates the charset the subject is using, the B indicates that the remaining data is Base64 encoded and everything between the subsequent ? and ?= is the Base64 encoded subject. Quoted Printable is also supported and the same subject in quoted printable would appear as such:

Subject: =?ISO-8859-1?q?This=20is=20a=20test?=

What we ran into is that particularly long subjects were not being unencoded. As the message went through conversion we would truncate the subject to a maximum of 255 characters (while also appending "..."). What resulted was a rather unreadable subject in any client, whether it be Outlook, OWA, or your favorite POP/IMAP based reader. What we found is that, by default, Exchange Server 2007 will not attempt to decode any subject header that exceeds a total encoded length greater than 255 characters.

To resolve this you have to make the following changes on your Hub Servers (this has no affect on Edge):

  1. In the \Exchange Server\Bin directory, open the EdgeTransport.Exe.Config file.

  2. It should start with something that looks similar to:
        <gcServer enabled="false" />
    ...and so on.

  3. Add the following lines between the <configuration> and <runtime> elements:
      <section name="CTS"
    type="Microsoft.Exchange.Data.Internal.CtsConfigurationSection, Microsoft.Exchange.Data.Common, PublicKeyToken=31bf3856ad364e35, version=8.0.681.0,
        <MaximumEncodedWordLength Value="512"/>

  4. Save and exit the .config file. 

  5. Restart the MSExchangeTransport service.

  6. Resubmit your message and confirm the fix is working

Note: Step 3. The version does not need to be change based on the version of Exchange (E2K7 SP1, SP1 RU7, etc,.) that you have installed.

Base64 and Quoted-Printable encoding is going to introduce some additional bloat to the subject length so whatever value you set in the MaximumEncodedWordLength will need to support your maximum encoded values. 

Please note: No matter how long of a subject you submit, Exchange will ultimately truncate the unencoded version of that subject down to 255 characters and append "...".

Comments (3)

  1. Anonymous says:

    Would you also have a solution for Exchange 2003 SP2? We have various mails in the queues appearing with a subject like =?iso-8859-1?…

    That refers to Western Europe, which is also the character set defined in Internet Message Formats.

  2. pvangils,

    Can you explain a bit more? Encoded subjects are not in and of themselves a problem so I don’t understand the concern.

    The Exchange Server 2007 issue described above is a problem with our decoder when subject lines are encoded.

  3. Adam Gates says:

    Would it be possible to limit the same field? Prevent users from putting excessive amounts of data in the subject field?

Skip to main content