Open lenny76 opened 11 years ago
Use ImapClient.SetFlags(...)
.
I cannot make it works. setflag add flags to messages, but how to remove them? i cannot set message to unseen but I need to remove the "seen" flag the same for flagged flag etc...
thanks
:/ It seems there is an issue here. I'll get back to you.
Has this been resolved? I'm trying to do the same. It seems like there needs to be a removeFlag method that uses -FLAGS.SILENT(\Seen). All I see in the code is Replace() and Add (+) for flags, but not remove.
I'm fighting with this too, but it looks like you have to do a bitwise comparison ensuring removing the specific flag. Currently I've made a convenience method for me for easily setting/removing the 'flagged' (a.k.a 'Starred') flag:
private static void SetFlag(ImapClient client, MailMessage msg, bool flagged)
{
var currentflags = msg.Flags;
Flags newflag;
if (flagged)
newflag = currentflags | Flags.Flagged; //Ensure flagged
else
newflag = currentflags & ~Flags.Flagged; //Ensure not flagged
if (msg.Flags != newflag)
client.SetFlags(newflag, msg); //Only set flag if flag is not yet applied
}
However, from time to time a get a somewhat cryptic error message, like: 1 FETCH (UID 9 FLAGS (\Flagged))
(being a System.Exception directly translating the servers' response, so not very straightforward to handle.)
Hi, how can I reset the message flag to unseen state? thanks Lenny