Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在go中将邮件标记为未读?_Go_Imap_Flags - Fatal编程技术网

如何在go中将邮件标记为未读?

如何在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的关键字的[]字符串。

我想在go中将IMAP发送的消息标记为未读。我不知道,“替换”函数的参数是什么。我正在使用

这是我的密码:

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
请注意,“替换”确实会删除所有标志。您必须处理(作为字符串值添加到接头)要保留的内容:

  • \看见
  • \回答
  • \标记
  • \删除
  • \草稿
  • \最近的
您可以从MessageInfo结构/标志中获取以前的值:

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)))