Quoted-printable decoding error in header 'Subject'.

0 votes
asked Apr 4, 2010 by Yarik (160 points)
edited Mar 23, 2011

Please help me. I get this error during retrieving email.

Message: Quoted-printable decoding error in header 'Subject'.

Exception: Core.EmailAccountManager.ImportEmails at cSVAqj.CkMqVUZ.ATsxQKZ(String , Int32 , Int32 ) at cSVAqj.CkMqVUZ.elhKQZ(String , Int32 , crJYrO ) at cSVAqj.CkMqVUZ.BrIywR(String ) at Rebex.Mime.Headers.Unstructured.clLXPXZ(ALmPMm ) at Rebex.Mime.MimeHeader.clLXPXZ(String , String ) at Rebex.Mime.MimeHeader.get_Value() at Rebex.Mime.MimeHeaderCollection.BGlmNGZ(String ) at Rebex.Mime.MimeMessage.get_Subject() at Rebex.Mail.MailMessage.get_Subject() at Core.EmailAccountManager.ImportEmails(Int32 emailAccountID) in D:\GO-NET Projects\Classica\CRM\Core\EmailAccountManager.cs:line 158

Applies to: Rebex Secure Mail
commented Apr 5, 2010 by Lukas Pokorny (100,670 points)
Can you please save the email using MailMessage object's Save method and mail it to us (support@rebex.net) for analysis? Alternatively, open it using notepad or a similar text editor and post the content of Subject header here. We should be able to help then!

1 Answer

0 votes
answered Apr 6, 2010 by Lukas Pokorny (100,670 points)
edited Apr 6, 2010

The error most likely occurred because the e-mail message's subject header was not properly encoded and could not be parsed by Rebex Mail.

The following code reproduces the same error:

string source = "Subject: =?us-ascii?Q?This_is_wrong_=_?=\r\n\r\nText"; 
MailMessage mail = new MailMessage();
mail.Load(System.Text.Encoding.ASCII.GetBytes(source));
string subject = mail.Subject;

This produces an exception when accessing the MailMessage object's Subject property.

Workaround 1: Prior to loading the message, enable IgnoreUnparsableHeaders option by adding the following line:

mail.Options |= MimeOptions.IgnoreUnparsableHeaders;

If the message was not loaded from a file, stream or byte array but retrieved from an Imap or Pop3 object instead, a corresponding IgnoreUnparsableHeaders is available for Imap.Options and Pop3.Options property (enable ImapOptions.IgnoreUnparsableHeaders or Pop3Options.IgnoreUnparsableHeaders, respectively).

Workaround 2: If accessing MailMessage.Subject fails, use the content of MailMessage.Headers["subject"].Raw instead. If possible, please let us know the content of this property, it might help us to determine what exactly is going on and perhaps enhance the parser to handle some kind of broken input as well.

...