Re: Extract zip file from email attachment

2007-04-06 Thread Gabriel Genellina
Basilisk96 wrote: > > > > Could the file like object still be encoded in MIME or something? > > > > Yes it is. You don't need to seek(0). > Try this: > > decoded = email.base64mime.decode(part.get_payload()) > fileObj.write(decoded) Or better: decoded = part.get_payload(decode=True) fileObj.write

Re: Extract zip file from email attachment

2007-04-06 Thread Gabriel Genellina
Basilisk96 wrote: > > > > Could the file like object still be encoded in MIME or something? > > > > Yes it is. You don't need to seek(0). > Try this: > > decoded = email.base64mime.decode(part.get_payload()) > fileObj.write(decoded) > > > -Basilisk96 -- http://mail.python.org/mailman/listinfo/py

Re: Extract zip file from email attachment

2007-04-06 Thread Basilisk96
> > Could the file like object still be encoded in MIME or something? > Yes it is. You don't need to seek(0). Try this: decoded = email.base64mime.decode(part.get_payload()) fileObj.write(decoded) -Basilisk96 -- http://mail.python.org/mailman/listinfo/python-list

Re: Extract zip file from email attachment

2007-04-06 Thread erikcw
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() > > cStri

Re: Extract zip file from email attachment

2007-04-05 Thread Gabriel Genellina
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

Re: Extract zip file from email attachment

2007-04-05 Thread erikcw
On Apr 5, 8:00 pm, hlubenow <[EMAIL PROTECTED]> wrote: > erikcw wrote: > > Hi all, > > > I'm trying to extract zip file (containing an xml file) from an email > > so I can process it. But I'm running up against some brick walls. > > I've been googling and reading all afternoon, and can't seem to f

Re: Extract zip file from email attachment

2007-04-05 Thread hlubenow
erikcw wrote: > Hi all, > > I'm trying to extract zip file (containing an xml file) from an email > so I can process it. But I'm running up against some brick walls. > I've been googling and reading all afternoon, and can't seem to figure > it out. > > Here is what I have so far. > > p = POP3(

Extract zip file from email attachment

2007-04-05 Thread erikcw
Hi all, I'm trying to extract zip file (containing an xml file) from an email so I can process it. But I'm running up against some brick walls. I've been googling and reading all afternoon, and can't seem to figure it out. Here is what I have so far. p = POP3("mail.server.com") print p.getwelco