Python:Email and Header Parsing: Some Help

dont bother dontbotherworld at
Thu Feb 26 09:51:40 CET 2004

I have written this small piece of code. I am a brand
new  player of Python. I had asked some people for
help, unfortunately not many helped.
Here is the code I have:

import email
import os
import sys
fread = open('email_message', 'r')
print msg
#fwrite = open('output','w')

This way I am able to print the entire email message
on the stdout. The program generates an error If I try
to write the output to a file-- It says the argument
(here msg) should be a string but not as an instance
like here. How to write the message to another file

2. I have so many headers in the email message

X Received:
X Priority:
etc etc.
I want to parse the headers separtely and message
separately. Does anyone has an example code to deal
with Parser?
Also I want to remove the redundant words and all html
tags. Any advise on that?
I saw some examples using HTMLGen But I dont have
HTMLGen with python on my machine. I have Python
2.3.3. on my machine.

All help is greatly appreciated.

Do you Yahoo!?
Get better spam protection with Yahoo! Mail.

More information about the Python-list mailing list