open a mail and...

Tim Williams (gmail) tdwdotnet at gmail.com
Fri Jul 15 09:51:23 EDT 2005


On 7/15/05, Alberto Vera <avera at coes.org.pe> wrote:
>
> Hello
>
> Is it possible to open a mail and download its files attached in a hard-disk
> using a python script?
>
> Regards
> --
> http://mail.python.org/mailman/listinfo/python-list
>

yes, use the email module.

>>> msg = email.message_from_file(an_opened_file)
or
>>> msg = email.message_from_string(a_mail_string)

then use:

For part in msg.walk():
   do_something(part)

The email docs will help you with converting and extracting the
specific attachements you are expecting

HTH :)



More information about the Python-list mailing list