2010-11-30 42 views
0

我试图从使用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库删除电子邮件? 是否还有其他Imap库与c#一起使用?当我看到这是我发现的唯一一个。

回答

0

你的代码看起来像它应该根据http://imapnet.codeplex.com/Thread/View.aspx?ThreadId=73377工作,我也看到你在那里发布。你有没有尝试设置一个Gmail帐户,并对其进行测试,只是为了看看会发生什么?

至于其他图书馆,我在以前的项目中使用了EAGetMail POP3 & IMAP4组件(因为我的新帐户,无法添加链接:www.emailarchitect.net/eagetmail/),并且祝您好运。

+0

我正在使用gmail帐户测试此代码。我会看看你列出的库。 – Justin808 2010-11-30 20:01:48