英文:
How to mark a message as read , \Seen on IMAP ( Go )
问题
我正在尝试使用IMAP(Internet Mail Access Protocol)将一条消息/一组消息标记为“\SEEN”(永久性标记)。然而,与fetch、search和其他功能不同,IMAP包中似乎没有Flag函数。我应该使用UIDs发送原始命令吗?
英文:
I'm trying to mark a message/list of messages as "\SEEN" (permanently) using IMAP . However unlike fetch, search and friends there seem to be no Flag function on the imap package. Should I send raw commands with the UIDs ?
答案1
得分: 4
你必须将邮箱选择为可写的。
youImapConnection.Select(mailboxName, false) // true 表示只读
然后简单地执行以下操作:
seq, _ := imap.NewSeqSet("")
err := seq.AddNum(612) // 612 是你的 UID
_, err = imap.Wait(youImapConnection.UIDStore(seq, "+FLAGS", imap.NewFlagSet(`\Seen`))) // 在这里告诉它添加标记 \Seen
最后,你需要清除已删除的邮件:
_, err := imap.Wait(youImapConnection.Close(true)) // 在这里告诉它应用更改,如果你标记了一封邮件为已删除,这是必要的
然后你就完成了
如果有需要,不要犹豫浏览文档/源代码,它很容易理解,你会找到所需的一切。
英文:
You have to select the mailbox as writable
youImapConnection.Select(mailboxName, false) // true would be for readonly
And then simply do the following
seq, _ := imap.NewSeqSet("")
err := seq.AddNum(612) // 612 is your UID
_, err = imap.Wait(youImapConnection.UIDStore(seq, "+FLAGS", imap.NewFlagSet(`\Seen`))) // Here you tell to add the flag \Seen
Finally you will have to expunge:
_, err := imap.Wait(youImapConnection.Close(true)) // Here you tell to apply changes, necessary if you mark an Email as deleted
And you should be good
And do not hesitate to browse the doc/source code, it's easy to understand and you'll find all you need.
答案2
得分: 2
IMAP使用STORE
命令在消息上设置标志,例如:
foo UID STORE 135211 +FLAGS (\Seen)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论