ToMailMessage() - An invalid character in Header

115 views Asked by At

I have got a console application that processes emails in a mailbox using OpenPOP, it is failing on one email with the following exception

An invalid character was found in the mail header: '\u007f

The code it is calling is the following

            MailMessage _testMail = emailFile.ToMailMessage();               
            _testMail.BodyEncoding = Encoding.UTF8;
            _testMail.Subject = _testMail.Subject + " Issue ID: " + callid;

it is failing when it calls emailFile.ToMailMessage() and help would be appreciated

1

There are 1 answers

0
germi On BEST ANSWER

\u007f is the DELETE character - that seems to be invalid in your context. You might have to strip unwanted characters from your input before calling .ToMailMessage.