How to mark messages as read?

Topics: Help requests
Dec 30, 2013 at 4:04 PM
I am successfully searching for messages using the "(UNSEEN)" flag, but I'm having some difficulties marking them as read or "SEEN".

This is what I've tried so far:

currentEmail.Flags.Remove("UNSEEN");
currentEmail.Flags.Add("SEEN");

as well as:

currentEmail.Flags.Remove("(UNSEEN)");
currentEmail.Flags.Add("(SEEN)");

I also tried just adding the SEEN flag (so removing the first line of code), but none of these worked - the email remains UNSEEN (unread). To be specific, this is a Google Apps (Gmail) account.

How would I go about this?
Coordinator
Dec 30, 2013 at 4:32 PM
Edited Dec 30, 2013 at 4:33 PM
Hi deusdies,

you can use the Message.Seen property directly:
currentEmail.Seen = true;
PS: Note to your code: the flag SEEN does not exist. The message can only have the UNSEEN, and be seen when it is not set.

Greets,

Pavel
Dec 30, 2013 at 4:34 PM
Thanks - that worked!

Cheers,
Bogdan
Coordinator
Dec 30, 2013 at 4:41 PM
You're welcome!
Another thing I want to mention, for a more easy handling of flags, you can use the constants in ImapX.Flags.MessageFlags:
using ImapX.Flags;

/*...*/
currentEmail.Flags.Add(MessageFlags.Answered);
--Pavel