Invalid command while attempting to set Read flag

Nov 30, 2010 at 4:16 PM

Hello,

 

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();
    flags.Add("Read");
    inbox.AddFlags(ids[i], flags);
  }
}

 

 

Any idea what I am doing wrong?

Nov 30, 2010 at 7:04 PM
Edited Nov 30, 2010 at 7: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 7:40 PM

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