Deleting Messages

Nov 29, 2010 at 9:17 PM

Hello,

 

I'm trying to delete messages from the mailbox but am having a lot of problems. The code I am using to delete the messages is :

 

            // Brute force delete
            _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);
            }

The output I get is:

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.()

That's repeated a few 100 times. Some of the messages are deleted, but not all of them. Is there a better way to be deleting messages?

Thanks,
Justin

Coordinator
Dec 10, 2010 at 7:42 PM

I am concerned about your error messages it seems as m.MessageID is empty being that nothing is displaying in the parenthesis. Can you output m.ID as well and possibly obtain a list of id's. This can be done using the diagnostic tool.