February 17th, 2004, 10:52 AM
imaplib - retrieving and deleting files
I am writing a piece of code that retrieves emails from a server and is processing them accordingly (testing for spam). To add some additional functionality, I wish to delete emails from the server (in my case 'moppsy.comp.glam.ac.uk') once they have been read.
Does anyone have any knowledge or experince of doing this?
The function in which I connect to the server and retrieve the emails is below.
Edit: Added tags.
m = imaplib.IMAP4('moppsy.comp.glam.ac.uk')
typ, data = m.search(None, 'ALL')
for num in string.split(data):
print "Email Number:", num
typ, data = m.fetch(num, '(RFC822)')
Last edited by netytan; February 17th, 2004 at 12:29 PM.
February 17th, 2004, 11:46 AM
Well, I can't seem to find a function to delete a message in imaplib, but I found one to expunge deleted ones ... odd. Other than using the send() method to send a raw command to delete a message, I am not sure how one would accomplish this.