Reading message bodies with charset="utf-8"

Giganews Newsgroups
Subject: Reading message bodies with charset="utf-8"
Posted by:  Nick Sivo (junk6indyforu…@kogir.com)
Date: Tue, 29 Aug 2006

Hello,

I'm attempting to use Indy Pop3 to retrieve and process some email messages with the following properties:

Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0

I'm using C#, .NET 2.0 and VS 2005 on x86.

After declaring msg as
  Indy.Sockets.Message msg = new Indy.Sockets.Message();
and populaitng msg successfully by calling
  iPOP3.Retrieve(1, msg);
I am unable to access the message body.  The msg.Body.Text property mangles the UTF-8 text, and both msg.Body.SaveToStream() and msg.Body.SaveToFile() are unimplemented.  I tried searching msg.MessageParts, but since the message is not mime encoded, there are no parts (msg.MessageParts.Count = 0).  In an unsuccessful act of desperation I tried treating each character in msg.Body.Text as a byte and parsing the resulting byte array, but it too was invalid.

Is there a way to get the raw bytes of the body so I can properly parse them?

Thanks for your time,
Sincerely,
Nick Sivo

Replies