IMAP - get size of mailboxes
valinor at linuxmail.org
Fri Sep 10 14:20:43 CEST 2004
I'm trying to make a script (or similar) to display and print the
folder size information for my outlook mailbox.
(So nothing for exchange administrators, just for my own mailbox
that keeps bouncing against the 45 MB limit ...)
The standard way (right-click on Outlook Today, Properties:Folder Size...)
number of deficiencies:
- the window is fixed size, so you can either see the full folder name or
- can't sort by size,
- can't print
So I came up with the folloing approach:
Please correct any flaws you see, since I'm new into python.
The problem (except for bad coding) is that I can't think of a way to get
the size of the mailbox.
Ideas any one?
user = os.environ['USER']
imap_server = "xxx-yyy.com"
# Open a connection to the IMAP server
M = imaplib.IMAP4(imap_server)
result,list = M.list()
print "%-30s%5s%10s\n" % ("Folder", "no Msg", "Result")
for item in list[:]:
x = item.split()
mailbox = string.join(x[2:])
result, size = M.select(mailbox,readonly=1)
print "%-30s%5d%10s" % (mailbox, int(size), result);
More information about the Python-list