Reputation: 9423
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?=
Upvotes: 2
Views: 1371
Reputation: 8682
I am one of the developer of OpenPop.NET, and as of now a new release have been made. You should not see any problems parsing any emails in OpenPop.NET anymore. If you find any - please let us at our mailing list. We even implemented a test case for your specific subject - just to make sure.
Upvotes: 1
Reputation: 9423
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;
Upvotes: 1