[Chicago] imaplib and gmail... the inbox count is wrong! Wrong, I tell ya!

Fawad Halim fawad at fawad.net
Sat Feb 21 03:44:18 CET 2009

  It works for me.

>>> mail.select('INBOX')[1]
>>> mail.select('[Gmail]/All Mail')[1]

The INBOX count I'm getting is consistent with the number of messages
in my inbox (read and unread).


On Fri, Feb 20, 2009 at 6:43 PM, Jason Huggins <jason at jrandolph.com> wrote:
> Hiya, folks!
> I tried googling this, but nothing came up in my quest... so I'm
> switching to "Let's ask some humans" mode.
> I'm trying to get an accurate count of the total number of messages
> (read and unread) in my Inbox.
> Here's my code:
>>>> import imaplib
>>>> mail = imaplib.IMAP4_SSL('imap.gmail.com', 993)
>>>> mail.login('larry at gmail.com','sergey_is_my_homeboy')
> ('OK', ['larry at gmail.com authenticated (Success)'])
>>>> status, count = mail.select ('Inbox')
>>>> status, count
> ('OK', ['9332'])
> If I log into Gmail through the web, the inbox count is different (and
> thousands less than 9332). The 9332 number appears to be the number if
> I open "All Mail" through the web. Is there a way to *just* get the
> number of messages in the inbox? It feels like the above code should
> give me the accurate number, but it's not.
> Thanks!
> - jason
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago

More information about the Chicago mailing list