Fw: WhatamI doing wrong ? (re: About Content-Transfer-Encoding)

Dhirja Gangopadhyay dhirja at vsnl.net
Tue Jan 23 10:56:03 EST 2001


Idea:
Could I be I going wrong because I am encoding string by string rather than
the whole file at once ? (That does create a problem, though - how do I
convert all the lists I write to the body into a file first !)

Thanks, Oleg for the link. I am unable to FTP the link from that link,
however. My connection is really frustrating.

Thanks

Sandipan

----- Original Message -----
From: "Dhirja Gangopadhyay" <dhirja at vsnl.net>
To: <python-list at python.org>
Sent: Tuesday, January 23, 2001 8:54 PM
Subject: WhatamI doing wrong ? (re: About Content-Transfer-Encoding)


> I did the following few things in this:
>
> I found on a Google Search -
> http://www.linuxsolutions.demon.co.uk/PythonPages2.html
>     subwriter = w.nextpart()
>     subwriter.addheader("Content-Transfer-Encoding", "base64")
>     subwriter.addheader("Content-Disposition", 'attachment; filename="%s"'
%
> _fileName)
>     f = subwriter.startbody('application/octet-stream; name="%s"' %
> _fileName)
>     subwriter.flushheaders()
>     base64.encode(open('./%s' % _fileName, 'r'), f)
>     w.lastpart()
>
> Where I learnt to change my:
>
>     listLines = ['zxczxc','werwerwer']
>     subwriter = w.nextpart()
>     f = subwriter.startbody('text/html')
>     subwriter.flushheaders()
>     f.writelines(listLines)
>     w.lastpart()
>
> To:
>
>     def mthEncoder(lstLines):
>         import base64
>         tmpList = []
>         for lstLine in lstLines:
>             tmpList.append(base64.stringencode(lstLine))
>         return tmpList
>
>     listLines = ['zxczxc','werwerwer']
>     subwriter = w.nextpart()
>     subwriter.addheader("Content-Transfer-Encoding", "base64")
>     subwriter.addheader("Content-Disposition", 'inline')
>     f = subwriter.startbody('text/html')
>     subwriter.flushheaders()
>     f.writelines(mthEncoder(listLines))
>     w.lastpart()
>
> Works fine on the server. The e-mail goes out.
>
> But when received on the Outlook Express 5.5 client, the strings are all
> mangled.
> I cant figure out why. What am I doing Wrong ?
>
> Thanks
>
> Sandipan
>
> PS. I am using Dhirja's account as my ISP's SMTP server is down !
>
> ----- Original Message -----
> From: "Dhirja Gangopadhyay" <dhirja at vsnl.net>
> To: <python-list at python.org>
> Sent: Tuesday, January 23, 2001 7:32 PM
> Subject: About Content-Transfer-Encoding
>
>
> > I use the MimeWriter module to build a MIME body that I then send over
> SMTP
> > using smtplib.
> >
> > How can I force content-transfer-encoding to base64 ?
> > Content-type is text/plain, text/html and text/xml.
> >
> > Thanks,
> >
> > Sandipan
> >
> >
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>






More information about the Python-list mailing list