deleting a message with imaplib

Donn Cave donn at drizzle.com
Mon Aug 19 17:21:35 CEST 2002


Quoth Gerhard Hring <gerhard.haering at opus-gmbh.net>:
| Am I blind or does Python's imaplib really have no means of deleting a
| message on the IMAP server? Anybody knows a patch or a workaround?

You are blind!  OK, it isn't the most obvious thing.  IMAP deletes
in two stages:  first, set the Deleted flag, then you can issue an
EXPUNGE command that rewrites the folder and leaves out the Deleted
messages (assuming exclusive access.)

  ok, detail = imap.store('5', '+Flags', '(\Deleted)')
  ...
  ok, detail = imap.expunge()

	Donn Cave, donn at drizzle.com



More information about the Python-list mailing list