saving .zip or .txt email attachments instead of deleting them

John Roth newsgroups at jhrothjr.com
Thu Jun 2 17:15:38 EDT 2005


"scrimp" <scrimp212 at yahoo.com> wrote in message 
news:1117746435.769666.186810 at z14g2000cwz.googlegroups.com...
> How would I go about retriving an email message and stripping out the
> attachment into a file. I have seen examples where they would read in
> the file and delete the attachment and replace it with text saying that
> the attachment was removed.
>
> For testing purposes Im using a pop3 server to receive messages from. I
> can log into the pop3 server get all the messages and print them to the
> screen or to a file.
>
> I have another script that I got from ActiveSource that deletes the
> attachment. This is where I will need to save the attachment instead of
> deleting it. Any help is appreciated thanks!

Look at the documentation for the email module in the Python Library
Reference. The final example shows how to read an email and save
all the parts into a directory. It's almost usable as is; I had to tweak
it just a little for what I wanted it to do.

John Roth

>
> --Barry
> 




More information about the Python-list mailing list