Problems decoding and writing mail attachment
aleax at aleax.it
Mon Aug 4 13:22:16 CEST 2003
> I've written a script which I use to save attached binary files from
> e-mails to disk. The core is simply:
> decodedfile = bas64.decodestring(attachment)
> fle = open('image.jpg','wb')
> However, the files written to disk are regularly incomplete, i.e.
> jpg's having a grey bar at the bottom, gif's don't even display, pdf's
> give errors.
> What am I doing wrong here?
You're not calling fle.close -- you lack parentheses after the
method, so you're just mentioning it, NOT calling it. Not sure
if that's your problem (seems unlikely), but it most definitely
IS something you're doing wrong, so I thought I'd point it out.
More information about the Python-list