
February 17th, 2004, 10:52 AM
|
|
Contributing User
|
|
Join Date: Oct 2003
Posts: 146
Time spent in forums: 12 h 27 m 38 sec
Reputation Power: 10
|
|
|
imaplib - retrieving and deleting files
Hi all,
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.
Code:
def collectEmail():
m = imaplib.IMAP4('moppsy.comp.glam.ac.uk')
m.login(getpass.getuser(), getpass.getpass())
m.select()
typ, data = m.search(None, 'ALL')
print data
for num in string.split(data[0]):
print "\n"
print "Email Number:", num
typ, data = m.fetch(num, '(RFC822)')
handleEmail(data[0][1])
m.logout()
Edit: Added tags.
Cheers
Tryst
__________________
Tryst
Last edited by netytan : February 17th, 2004 at 12:29 PM.
|