Hello,
I received an email with attachment. The attachment can be binary or text.
How do I extract and save the message to database and attachment to some folder?

(f_name,f_email)=email.Utils.parseaddr(m['from'])
(t_name,t_email)=email.Utils.parseaddr(m['to'])
(r_name,r_email)=email.Utils.parseaddr(m['reply_to'])
subject = m['subject']
 body=m.get_payload()

Since payload is multipart now. get_payload will be a list of parts.

1. How can i do:

for i in m.get_payload():
    save text to db (or extract text as string)
    save attachment to file with correct extension [.xml .exe .doc
.pdf] (How can i extract file so i can do f.write(file) )

2.How can i distinguish what is what?  Will get_payload() display text
first and then attachment?


Thanks
Lukasz
_______________________________________________
Email-SIG mailing list
[email protected]
Your options: 
http://mail.python.org/mailman/options/email-sig/archive%40mail-archive.com

Reply via email to