Get unseen messages via IMAP <p>I need to extract some data from new (unseen) messages; I'm trying to make range of that data:</p> <pre><code>c, _ = imap.Dial("someserverr") defer c.Logout(30 * time.Second) fmt.Println("Server says hello:", c.Data[0].Info) c.Data = nil if c.State() == imap.Login { c.Login("somedata", "somedata") } c.Select("INBOX", false) set, _ := imap.NewSeqSet("") fmt.Println("unseen", c.Mailbox.Unseen) fmt.Println(c.Mailbox) if c.Mailbox.Unseen &gt;= 1 { set.AddRange(1, c.Mailbox.Unseen) } else { set.Add("0:0") } </code></pre> <p>The main problem here is command <code>c.Mailbox</code> showing wrong number of unseen messages.</p> <p>For example, if I have 5 unread messages in INBOX it shows 1. If I mark that one as read, it will show 4, and so on.</p>