Koolwired.Imap - 如何删除邮件?

时间:2010-11-30 19:29:54

标签: c# 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库吗?当我看到这是我找到的唯一一个。

1 个答案:

答案 0 :(得分:0)

您的代码看起来应该符合http://imapnet.codeplex.com/Thread/View.aspx?ThreadId=73377的要求,我也看到您在那里发布了。您是否尝试过设置一个Gmail帐户并对其进行测试,看看会发生什么?

至于其他图书馆,我使用过EAGetMail POP3& IMAP4组件(由于我的新帐户无法添加链接:www.emailarchitect.net/eagetmail/)以前的项目并且运气不错。