2010-11-30 33 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