如何在go中将邮件标记为未读?
我想在go中将IMAP发送的消息标记为未读。我不知道,“替换”函数的参数是什么。我正在使用 这是我的密码:如何在go中将邮件标记为未读?,go,imap,flags,Go,Imap,Flags,我想在go中将IMAP发送的消息标记为未读。我不知道,“替换”函数的参数是什么。我正在使用 这是我的密码: set, _ := imap.NewSeqSet("") set.AddNum(45364) // 45364 is message's UID _, err = imap.Wait(c.UIDStore(set, "+FLAGS", imap.Replace())) 看一下和的文档,它看起来有点凌乱。调查Replace的源代码时,它只需要一个带有来自RFC3501的关键字的[]字符串。
set, _ := imap.NewSeqSet("")
set.AddNum(45364) // 45364 is message's UID
_, err = imap.Wait(c.UIDStore(set, "+FLAGS", imap.Replace()))
看一下和的文档,它看起来有点凌乱。调查Replace的源代码时,它只需要一个带有来自RFC3501的关键字的[]字符串。比如说
flags := []string{}
// ....
_, err = imap.Wait(c.UIDStore(set, "+FLAGS", imap.Replace(flags)))
// Since the "\Seen" is not in splice, the message will be unseen
请注意,“替换”确实会删除所有标志。您必须处理(作为字符串值添加到接头)要保留的内容:
- \看见
- \回答
- \标记
- \删除
- \草稿
- \最近的
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)
}
你可以用另一种方法。您可以删除该标志。例如:
flags := `\Seen`
tmpSet, _ := imap.NewSeqSet("")
tmpSet.AddNum(emailUid)
_, err = imap.Wait(c.UIDStore(tmpSet, "-FLAGS", imap.NewFlagSet(flags)))