Use 2-legged OAuth to access IMAP then you don't need to know user logins or 
require their authorization. You don't need to get all messages to get the 
unread count, it's as simple as:

import imaplib, re
conn = imaplib.IMAP4_SSL("imap.gmail.com", 993)
conn.login(username, password)               # This line would be replaced 
with the OAuth Authentication
unreadCount = re.search("UNSEEN (\d+)", conn.status("INBOX", 
"(UNSEEN)")[1][0]).group(1)

that code was blatantly stolen from:

http://stackoverflow.com/questions/953561/check-unread-count-of-gmail-messages-with-python

Jay

-- 
You received this message because you are subscribed to the Google Groups 
"Google Apps Domain Information and Management APIs" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-apps-mgmt-apis/-/ObOLqajlL7kJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-apps-mgmt-apis?hl=en.

Reply via email to