Extract zip file from email attachment

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Apr 6 06:51:47 CEST 2007

erikcw wrote:

>         resp = p.retr(msg_num)
>         if resp[0].startswith('+OK'):

You don't have to check this; errors are transformed into exceptions.

>                     fileObj = StringIO.StringIO()

cStringIO is faster

>                     fileObj.write( part.get_payload() )

You have to reset the file pointer to the beginning: fileObj.seek(0),
else ZipFile will not be able to read the contents.

Gabriel Genellina

More information about the Python-list mailing list