On Apr 6, 12:51 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > 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
Hi Gabriel, I added fileObj.seek(0) on the line directly after fileObj.write( part.get_payload() ) and I'm still getting the following error. Traceback (most recent call last): File "wa.py", line 209, in <module> attachment = zipfile.ZipFile(fileObj) File "/usr/lib/python2.5/zipfile.py", line 346, in __init__ self._GetContents() File "/usr/lib/python2.5/zipfile.py", line 366, in _GetContents self._RealGetContents() File "/usr/lib/python2.5/zipfile.py", line 378, in _RealGetContents raise BadZipfile, "File is not a zip file" zipfile.BadZipfile: File is not a zip file Could the file like object still be encoded in MIME or something? Thanks! Erik -- http://mail.python.org/mailman/listinfo/python-list