Script to fetch IMAP unread
Script to fetch IMAP unread / unseen message counts?
Gerhard =?unknown-8bit?Q?H=E4ring?= gerhard.haering at gmx.deMon Feb 17 16:39:21 EST 2003
- Previous message (by thread): Errors during 'make' of Python 2.2.2 - /usr/local/include a non-system directory?!
- Next message (by thread): Script to fetch IMAP unread / unseen message counts?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
* John J Lee <jjl at pobox.com> [2003-02-17 20:51 +0000]: > Anybody have one? > > Google found a couple on a newsgroup, but the URLs given are broken. Here's a one that I used on my home intranet ;-) #v+ #!/usr/bin/env python import imaplib class ImapCheckResult: def __init__(self): self.unseen_messages= 0 self.new_messages = 0 def __repr__(self): return "Unseen: %i, New: %i" % (self.unseen_messages, self.new_messages) def check_imap_folder(host, user, passwd, foldername): result = ImapCheckResult() imap = imaplib.IMAP4(host) imap.login(user, passwd) typ, data = imap.select(foldername, 1) typ, data = imap.search(None, 'UNSEEN') result.unseen_messages = len(data[0].split()) typ, data = imap.search(None, 'NEW') result.new_messages = len(data[0].split()) imap.logout() return result def main(): print check_imap_folder("myhost", "myuser", "mypass", "INBOX") if __name__ == '__main__': main() #v- Gerhard -- Favourite database: http://www.postgresql.org/ Favourite programming language: http://www.python.org/ Combine the two: http://pypgsql.sf.net/ Embedded database for Python: http://pysqlite.sf.net/
- Previous message (by thread): Errors during 'make' of Python 2.2.2 - /usr/local/include a non-system directory?!
- Next message (by thread): Script to fetch IMAP unread / unseen message counts?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list