My simple script parse output screen and to a new file!
Chuck Amadi
chuck at smtl.co.uk
Thu Jun 10 09:54:30 EDT 2004
Cheers for pointing that out !.
By the way list is there a better way than using the readlines() to parse the
mail data into a file , because Im using email.message_from_file it returns
all the data i.e reads one entire line from the file , headers as well as just
the desired body messages .
fp = file("/home/chuck/pythonScript/testbox")
mb = mailbox.UnixMailbox(fp, email.message_from_file)
#<Instead of this >
mailout = file("/home/chuck/pythonScript/SurveyResults.txt","w")
for mail in fp.readlines():
mailout.write(mail)
#<Something like this>
for mail in mb:
body = mail.get_payload()
mailout.write(body) # write only the body messages to SurveyResults.txt
Cheers if the is a better way I can't get my head round how I can print mail (
only the body messages) to screen and the entire mail headers and body to the
new file.
More information about the Python-list
mailing list