I'm one of the latter people, and were it not for the example, I'd
have no clue how to read messages with the API. After some poking
around, I'm still clueless about how to delete the messages I've read:
import getpass, imaplib
M = imaplib.IMAP4()
M.login(getpass.getuser(), getpass.getpass())
M.select()
typ, data = M.search(None, 'ALL')
for num in data[0].split():
typ, data = M.fetch(num, '(RFC822)')
print 'Message %s\n%s\n' % (num, data[0][1])
# DELETE THE MESSAGE HERE
M.logout()
Can someone hook me up?
-wsv
> Can someone hook me up?
I think IMAP does not have the notion of immediately deleting
messages. Instead, you should set the \Deleted flags, e.g. though
M.store(num, "+flags", r"\Deleted")
Then, deleted message will be expunged either as the result of
invoking .expunge(), or as a result of invoking .close().
Regards,
Martin