Koolwired.Imap - 如何删除消息?
我正在尝试使用 Koolwired.Imap 库删除邮箱中的所有电子邮件。我有以下代码应该标记所有消息,一旦标记完所有消息,就删除它们,
_mailbox = _command.Fetch(_mailbox);
foreach (ImapMailboxMessage m in _mailbox.Messages)
{
try
{
_command.SetDeleted(m.ID, true);
}
catch (Exception e)
{
Console.WriteLine("Marking Error: " + e.Message + "(" + m.MessageID + ")");
}
}
try
{
_command.Expunge();
}
catch (Exception e)
{
Console.WriteLine("Expunge Error: " + e.Message);
}
当我运行上面的代码时,我收到以下错误:
Marking Error: Input string was not in a correct format.()
Marking Error: No UID found for message number3()
Marking Error: No UID found for message number1()
Marking Error: Input string was not in a correct format.()
Marking Error: Input string was not in a correct format.()
Marking Error: Input string was not in a correct format.()
我看起来大多数消息 UID 都存在问题信息。运行后,大约 99% 的邮件不会被删除,只有 2-3 条被删除。如果我重新运行该程序,我会收到相同的错误,但错误会少一些,并且还会删除另外 2-3 封电子邮件。
我该如何使用 Koolwired.Imap 库删除电子邮件? 还有其他可与 C# 配合使用的 Imap 库吗?当我寻找时,这是我发现的唯一一个。
I'm trying to delete all the emails from a mailbox using the Koolwired.Imap library. I have the following code that should be marking all the messages and they, once all are marked, delete them,
_mailbox = _command.Fetch(_mailbox);
foreach (ImapMailboxMessage m in _mailbox.Messages)
{
try
{
_command.SetDeleted(m.ID, true);
}
catch (Exception e)
{
Console.WriteLine("Marking Error: " + e.Message + "(" + m.MessageID + ")");
}
}
try
{
_command.Expunge();
}
catch (Exception e)
{
Console.WriteLine("Expunge Error: " + e.Message);
}
When I run the above code i get the following errors:
Marking Error: Input string was not in a correct format.()
Marking Error: No UID found for message number3()
Marking Error: No UID found for message number1()
Marking Error: Input string was not in a correct format.()
Marking Error: Input string was not in a correct format.()
Marking Error: Input string was not in a correct format.()
I looks like there is an issue with the message UID on most of the message. After this runs about 99% of the messages are not deleted, some 2-3 are deleted. If I re-run the program, i get the same errors but a few less and another 2-3 emails are deleted.
How am I supposed to delete emails with the Koolwired.Imap library?
Are there other Imap libraries that work with c#? When i was looking this is the only one that I found.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码看起来应该按照 http://imapnet.codeplex.com/ 工作Thread/View.aspx?ThreadId=73377 我看到你也在那里发帖。您是否尝试过设置 Gmail 帐户并对其进行测试,看看会发生什么?
至于其他库,我使用过 EAGetMail POP3 和 EAGetMail POP3。 IMAP4 组件(由于我的新帐户而无法添加链接:www.emailarchitect.net/eagetmail/)在之前的项目中,并且祝您好运。
Your code looks like it should work according to http://imapnet.codeplex.com/Thread/View.aspx?ThreadId=73377 and I see you posted out there as well. Have you tried setting up a gmail account and testing it against that just to see what happens?
As for other libraries, I have used the EAGetMail POP3 & IMAP4 component (cannot add link due to my new account: www.emailarchitect.net/eagetmail/) on previous projects and had good luck with it.