Taking a look at RFC3501 and the documentation for Replace, it looks a bit messy. Investigating the source for Replace, it just wants a []string with the keywords from RFC3501. So, for example
flags := []string{}
// ....
_, err = imap.Wait(c.UIDStore(set, "+FLAGS", imap.Replace(flags)))
// Since the "\Seen" is not in splice, the message will be unseen
Please notice that Replace really removes all the flags. You have to handle (add to the splice as string values) what you want to preserve:
- \Seen
- \Answered
- \Flagged
- \Deleted
- \Draft
- \Recent
You can get the previous values from the MessageInfo struct / Flags:
type MessageInfo struct {
Attrs FieldMap // All returned attributes
Seq uint32 // Message sequence number
UID uint32 // Unique identifier (optional in non-UID FETCH)
Flags FlagSet // Flags that are set for this message (optional)
InternalDate time.Time // Internal to the server message timestamp (optional)
Size uint32 // Message size in bytes (optional)
}