To get the unseen emails use:
List<long> uids = imap.Search(Flag.Unseen);
If you are using GetMessageInfoByUID method to download most common email data fast:
List<MessageInfo> infos = imap.GetMessageInfoByUID(uids)
use MessageInfo.Envelope.Flags collection.
You can also download flags for a particular email or emails:
List<Flag> flag = imap.GetFlagsByUID(uids)
Please note that although IMAP defines 2 flags:
- \UNSEEN (Flag.Unseen)
- \SEEN (Flag.Seen)
and allows searching using both (imap.Search(Flag.Unseen), imap.Search(Flag.Seen)) in the Flags collection you'll only find \SEEN flag.
All 'negative' flags, are just a short forms of saying NOT having the flag. So \UNSEEN is equivalent to NOT \SEEN, when searching.
Lack of \SEEN flag (Flag.Seen) in the Flags collection, means that the message is unseen.