使用内联指定编码解析邮件主题

发布于 2024-09-06 07:19:41 字数 212 浏览 4 评论 0原文

我正在尝试解析在格式本身中指定编码的电子邮件主题。我得到了格式并想象如何做到这一点,但也许已经有任何免费的 .Net 解决方案可用,所以我不会在上面浪费时间?

这是我要解析的主题的示例:

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

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?=

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

等风来 2024-09-13 07:19:41

我发现了一个很棒的库,用于解析提到的字符串和整个邮件 - SharpMimeTools

它可以'无法自行从 POP3 服务器获取邮件(我使用 OpenPop.Net),但它可以很好地解析邮件。比 OpenPop.Net 解析器好得多

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;

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;
寻梦旅人 2024-09-13 07:19:41

我是 OpenPop.NET 的开发人员之一,目前新版本已经发布。在 OpenPop.NET 中解析任何电子邮件时,您应该不会再遇到任何问题。如果您发现任何内容 - 请通过我们的邮件列表告知我们。
我们甚至为您的特定主题实施了一个测试用例 - 只是为了确保这一点。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文