【问题标题】:how to flag imap message /Deleted via go imap library如何通过 go imap 库标记 imap 消息/已删除
【发布时间】:2015-10-03 18:04:13
【问题描述】:

我正在寻找开发 Go 代码以从 IMAP 服务器读取电子邮件,然后删除邮件(即标记它/已删除并删除)。这不是如何做到这一点,因为它似乎是一个无操作。变量 message_id 是一个 uint32 消息编号。

delset, _ := imap.NewSeqSet(string(message_id))
cmd2, err = client.Store(delset, "+FLAGS", "/Deleted")
if err != nil {
    fmt.Printf("Error on store command, err: %s\n", err)
    return
}
// below just stalls in a wait forever...
// Process responses while the command is running
// for cmd2.InProgress() {
//  // Wait for the next response (no timeout)
//  // client.Recv(-1)
//  // Process command data
//  for _, rsp2 = range cmd2.Data {
//      fmt.Println("Response from store")
//      fmt.Println(rsp2)
//  }
// }

// And later:
// Expunge
cmd3, err = client.Expunge(nil)

【问题讨论】:

  • 导入 ("code.google.com/p/go-imap/go1/imap" "fmt" "time" "net/mail" "bytes" "mime" "mime/multipart" "字符串”“io”“io/ioutil”“os”)
  • 标志拼写为\Deleted,这会产生很大的不同。

标签: go imap


【解决方案1】:

我被定向到作为包的一部分的演示代码中找到的答案。

https://github.com/mxk/go-imap/blob/master/imap-demo/demo1.go#L94

请注意,此包位置优先于 code.google.com 位置。而且,是的,标志是\已删除。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-11
    • 2019-03-31
    • 2012-04-26
    • 1970-01-01
    • 2022-06-11
    • 1970-01-01
    • 2011-01-16
    • 1970-01-01
    相关资源
    最近更新 更多