root/imapclient/examples/example.py

Revision 478:1485f576cae2, 0.9 KB (checked in by Menno Smits <menno@…>, 6 months ago)

Copyright date update for 2014

Line 
1# Copyright (c) 2014, Menno Smits
2# Released subject to the New BSD License
3# Please see http://en.wikipedia.org/wiki/BSD_licenses
4
5from __future__ import unicode_literals
6
7from imapclient import IMAPClient
8
9HOST = 'imap.host.com'
10USERNAME = 'someuser'
11PASSWORD = 'secret'
12ssl = False
13
14server = IMAPClient(HOST, use_uid=True, ssl=ssl)
15server.login(USERNAME, PASSWORD)
16
17select_info = server.select_folder('INBOX')
18print('%d messages in INBOX' % select_info['EXISTS'])
19
20messages = server.search(['NOT DELETED'])
21print("%d messages that aren't deleted" % len(messages))
22
23print()
24print("Messages:")
25response = server.fetch(messages, ['FLAGS', 'RFC822.SIZE'])
26for msgid, data in response.iteritems():
27    print('   ID %d: %d bytes, flags=%s' % (msgid,
28                                            data['RFC822.SIZE'],
29                                            data['FLAGS']))
Note: See TracBrowser for help on using the browser.