This project is read-only.

Invalid command while attempting to set Read flag

Nov 30, 2010 at 5:16 PM



Althought the operation actually did work, I get the following IMAP4 exception when calling AddFlags

Command \"store 1 +flags (\\read)\" failed : 101130113142500 BAD Invalid Command\r\n"

Here is my code.



 // connect to the imap4 server
imap.ConnectSsl(_kMailServer, _kImapSslPort);
imap.Login(_kUserName, _kPassword);

// Search unseen messages
Mailbox inbox = imap.SelectMailbox("inbox");
int[] ids = inbox.Search("UNSEEN");

// Download attachements found with each message
if (ids != null && ids.Length > 0)
  for (int i = 0; i < ids.Length; ++i)
    Message message = inbox.Fetch.MessageObject(ids[i]);

    // Mark the message as read
    FlagCollection flags = new FlagCollection();
    inbox.AddFlags(ids[i], flags);



Any idea what I am doing wrong?

Nov 30, 2010 at 8:04 PM
Edited Nov 30, 2010 at 8:34 PM

Hum... actually, the AddFlag command does not work. It's the inbox.Fetch.MessageObject() that raises the flag.

AddFlag does not work either if do not fetch the message.

Nov 30, 2010 at 8:40 PM

Ok found it. The name of the flag is "Seen". Not "Read".