Reputation: 1837
I have an code that opens my mail box. This is the code:
private Pop3Client GetPop3Client()
{
Pop3Client popClient = new Pop3Client();
popClient.Connect("smtp.xxxxxxxxx.xxxx.xx", 110, false);
popClient.Authenticate("username", "passowrd");
return popClient;
}
So, in that line:
Message message = popClient.GetMessage(1);
This error occurs:
'7bit' is not a supported encoding name. Parameter name: name at System.Globalization.EncodingTable.internalGetCodePageFromName(String name) at System.Globalization.EncodingTable.GetCodePageFromName(String name) at OpenPop.Mime.Header.HeaderFieldParser.ParseCharsetToEncoding(String characterSet) at OpenPop.Mime.MessagePart.ParseBodyEncoding(String characterSet) at OpenPop.Mime.MessagePart..ctor(Byte[] rawBody, MessageHeader headers) at OpenPop.Mime.MessagePart.ParseMultiPartBody(Byte[] rawBody) at OpenPop.Mime.MessagePart.ParseBody(Byte[] rawBody) at OpenPop.Mime.MessagePart..ctor(Byte[] rawBody, MessageHeader headers) at OpenPop.Mime.Message..ctor(Byte[] rawMessageContent, Boolean parseBody) at OpenPop.Pop3.Pop3Client.GetMessage(Int32 messageNumber) at DocumentCenter.Repository.ProcessMessage.ReadAllInMailBox() in C:\dsn\net\project\project.Repository\ProcessMessage.cs:line 414
How to fix it?
Upvotes: 1
Views: 948
Reputation: 38618
Since MailKit (NuGet package here) has a similar API to OpenPOP, you might try switching to MailKit instead as it does not have this problem (it properly deals with bad character encoding names when parsing messages).
If you don't want to change to MailKit, you'll need to edit the source code of OpenPOP and fix OpenPop.Mime.Header.HeaderFieldParser.ParseCharsetToEncoding() to properly handle bad charset names.
Upvotes: 2