SmtpClient does not encode mail header in conformance with RFC 2047
I am using .NET `SmtpClient` to send e-mail where the subject might contain characters outside of the ASCII range. The [RFC 2047][1] defines how e-mail text should be encoded when it contains special characters. Here is an example of a subject in an e-mail header:

    Subject: Votre enregistrement numéro 123

This should become, after encoding to ISO-8859-1:

    Subject: =?iso-8859-1?Q?Votre=20enregistrement=20num=E9ro=20123?=

where all special characters, including `?`, `=` (and others) and white space, are encoded using the `=xx` escape sequence.

However, when I look at what `SmtpClient` produces, I discover that it does not escape the white spaces, which means that the mail client receives this header:

    Subject: =?iso-8859-1?Q?Votre enregistrement num=E9ro 123?=

meaning that the encoding is broken with respect to (my reading of) RFC 2047. Some e-mail clients are perfectly happy with this incorrect encoding (most of them, in fact, including Outlook and gmail), but one (wanadoo.fr) displays the header in its raw format. This is not what the user should get to see :-(

Is there any known workaround for this issue?

  [1]: http://www.faqs.org/rfcs/rfc2047.html
SmtpClient does not encode mail header in conformance with RFC 2047
===

I am using .NET `SmtpClient` to send e-mail where the subject might contain characters outside of the ASCII range. The [RFC 2047][1] defines how e-mail text should be encoded when it contains special characters. Here is an example of a subject in an e-mail header:

    Subject: Votre enregistrement numéro 123

This should become, after encoding to ISO-8859-1:

    Subject: =?iso-8859-1?Q?Votre=20enregistrement=20num=E9ro=20123?=

where all special characters, including `?`, `=` (and others) and white space, are encoded using the `=xx` escape sequence.

However, when I look at what `SmtpClient` produces, I discover that it does not escape the white spaces, which means that the mail client receives this header:

    Subject: =?iso-8859-1?Q?Votre enregistrement num=E9ro 123?=

meaning that the encoding is broken with respect to (my reading of) RFC 2047. Some e-mail clients are perfectly happy with this incorrect encoding (most of them, in fact, including Outlook and gmail), but one (wanadoo.fr) displays the header in its raw format. This is not what the user should get to see :-(

Is there any known workaround for this issue?

  [1]: http://www.faqs.org/rfcs/rfc2047.html