Adding/removing message flags

The managemtn of message flags is done directly through adding and removing values to/from the Message.Flags collection. To make it easier, you can use the predefined values for message flags from ImapX.Flags.MessageFlags.

Adding flags

To add one or more message flags, you can us the Add, AddRange methods:

/* .. message = any message .. */  

// add one flag

// add multiple flags at once
message.Flags.AddRange(new[] { MessageFlags.Answered, MessageFlags.Flagged }); 

Removing flags

To remove one or more message flags, you can us the Remove, RemoveRange methods:

/* .. message = any message .. */  

// remove one flag

// remove multiple flags at once
message.Flags.RemoveRange(new[] { MessageFlags.Answered, MessageFlags.Flagged }); 

Important: The RECENT flag (MessageFlags.Recent) is managed by the server only!