tags:

views:

43

answers:

1

Hi, I'm trying to parse Email Subject which have encoding specified in format itself. I get the format and imagine how this can be done, but maybe there is any free .Net solution available already so I wouldn't waste time on it?

Here is an example of subject I want to parse:

=?ISO-8859-13?Q?Fwd=3A_Dvira=E8iai_vasar=E0_vagiami_da=FEniau=2C_bet_draust?=
A: 

I found a great library for parsing mentioned strings and whole mail in general - SharpMimeTools

It can't get mail from POP3 server on its own (I use OpenPop.Net for that) but it parses it nicely. Waay waaay muuuch better than OpenPop.Net parser

var popClient = new POPClient();
popClient.Connect("pop.test.lt", 110, false);
popClient.Authenticate("[email protected]", "test");

// Get OpenPop.Net message
var messageInfo = popClient.GetMessage(1, false);

// Covert raw message string into stream and create instance of SharpMessage from SharpMimeTools library
var messageBytes = Encoding.ASCII.GetBytes(rawMessage);
var messageStream = new MemoryStream(messageBytes);
var message = new SharpMessage(messageStream);

// Get decoded message and subject
var messageText = message.Body;
var messageSubject = message.Subject;
Sergej Andrejev