Koolwired.Imap - How do I delete messages?
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);
开发者_StackOverflow }
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.
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.
精彩评论