Re: simple script to read and output Mailbox body to file.
Hi again
I get output desired .Now to parse the fileobject and all body messages to an
external File named SurveyResults.t xt
Is this the correct way to go about it .
for mail in mbox:
# body = mail.get_payloa d()
# bodies.append(b ody)
# msg = mail.message_fr om_file(mail)
print 'mail'
print mail['Subject']
print mail.get_conten t_type()#text/plain
print mail.get_payloa d()
# break # just look at one message
# The File SurveyResults.t xt must all ready exist.
output = open("SurveyRes ults.txt", 'w') # mode 'w' means open the file for
writ-ing (any data already in the file will be erased)
mailout = mail.get_payloa d()
output. writelines(mail out)
output. close() # this is at end of the script
Here's my error but I thought mail is my file
Traceback (most recent call last):
File "getSurveyMailR ev2.py", line 37, in ?
mailout = mail.get_payloa d()
NameError: name 'mail' is not defined
Hi again
I get output desired .Now to parse the fileobject and all body messages to an
external File named SurveyResults.t xt
Is this the correct way to go about it .
for mail in mbox:
# body = mail.get_payloa d()
# bodies.append(b ody)
# msg = mail.message_fr om_file(mail)
print 'mail'
print mail['Subject']
print mail.get_conten t_type()#text/plain
print mail.get_payloa d()
# break # just look at one message
# The File SurveyResults.t xt must all ready exist.
output = open("SurveyRes ults.txt", 'w') # mode 'w' means open the file for
writ-ing (any data already in the file will be erased)
mailout = mail.get_payloa d()
output. writelines(mail out)
output. close() # this is at end of the script
Here's my error but I thought mail is my file
Traceback (most recent call last):
File "getSurveyMailR ev2.py", line 37, in ?
mailout = mail.get_payloa d()
NameError: name 'mail' is not defined
Comment