simple script to read and output Mailbox body to file.

Chuck Amadi chuck at smtl.co.uk
Tue Jun 8 11:48:51 EDT 2004


This now works ! as you stated below.Now all the body messages is this down 
using bodies [] list.

Cheers Chuck

mbox = mailbox.UnixMailbox(fp)
for mail in mbox:
	msg = email.message_from_file(mail)
	print `mail` #backticks
	print mail['Subject']
	print mailget_content_type()
	break #just look at one message

Gives me this:

chuck at sevenofnine:~/pythonScript> python getSurveyMail.py
mail
WWW Survey
text/plain
<wwwsurvey>
Country you are currently working in:<country>UNITED STATES</country>
Postal code or ZIP Code of your facility if you know it:<zipcode>
12345</zipcode>
Your Profession:<profession>Nurse</profession>
How long you have been qualifed:<qualified>< 1 Year</qualified>
Is Wound Management Your primary role:<iswoundmgt>A major part of your daily 
activities</iswoundmgt>
Specific area of interest in the list below:<specificareas>Veterinary 
medicine</specificareas>
Do you read a paper – based wm journal:<journal>Yes</journal>
If Yes your comments:<jcomments>bugs news</jcomments>
Favorite topics in the World Wide Wounds:<favorite>['Dressings information', 
'News']</favorite>
Further Information: required:<furtherinfo>all covered really</furtherinfo>
Your Email Address:<email>it at smtl.co.uk</email>
</wwwsurvey>


that works, then I done this 

msg.get_payload() should return the body. How about all the body messages in 
file.

Thanks





More information about the Python-list mailing list