Problems extracting attachment from email
foten
valinor at linuxmail.org
Fri Apr 8 03:03:42 EDT 2005
Lee Harr <lee at example.com> wrote in message news:<Wvg5e.727$uA3.224 at news02.roc.ny>...
> On 2005-04-07, foten <valinor at linuxmail.org> wrote:
> > The problem I'm having is when I'm trying to extract the
> > attachement using
> > f=open(Filename, "wb")
> > f.write(msg.get_payload(decode=1))
> > f.close()
> > Not the whole message is decoded and stored!
> > When only trying
> > f.write(msg.get_payload())
> > I see that the last 255 bytes are missing.
> >
>
>
> What happens if you do...
>
> m = msg.get_payload(decode=1)
> f.write(m)
> f.write(m)
> f.close()
> ?
>
> Just wondering if maybe some buffer not
> being flushed properly.
>
> Maybe could replace the 2nd f.write()
> with an f.flush()
Lee Harr <lee at example.com> wrote in message news:<Wvg5e.727$uA3.224 at news02.roc.ny>...
> On 2005-04-07, foten <valinor at linuxmail.org> wrote:
> > The problem I'm having is when I'm trying to extract the
> > attachement using
> > f=open(Filename, "wb")
> > f.write(msg.get_payload(decode=1))
> > f.close()
> > Not the whole message is decoded and stored!
> > When only trying
> > f.write(msg.get_payload())
> > I see that the last 255 bytes are missing.
> >
>
>
> What happens if you do...
>
> m = msg.get_payload(decode=1)
> f.write(m)
> f.write(m)
> f.close()
> ?
>
> Just wondering if maybe some buffer not
> being flushed properly.
>
> Maybe could replace the 2nd f.write()
> with an f.flush()
Thanx for the ideas!
If I do
f.write(m)
f.write(m)
nothing is changed. After the first write I'm missing 255 bytes and the
second write just doubles the data. After this I'm missing 510 bytes.
Doing a flush doesn't help either, if I'm not misstaken, calling close()
on a file inplicitly calls flush().
get_payload() fails to deliver the correct amount of data, in this case ~82k...
This drives my crazy!
More information about the Python-list
mailing list