This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vunruh
Recipients vunruh
Date 2010-07-19.03:04:54
SpamBayes Score 0.0006382022
Marked as misclassified No
Message-id <1279508696.99.0.665109757672.issue9298@psf.upfronthosting.co.za>
In-reply-to
Content
I'm using Python to email a text version and a PDF version of a report. The standard way of doing things does not work with Vista's Mail program, but works fine with Mail on OSX. So, I don't know if this is a Python or a Vista Mail bug. By standard way, I mean:

    # Add the attached PDF:
    part = MIMEApplication(pdf,"pdf")
    part.add_header('Content-Disposition', 'attachment', filename=pdfFile)
    msg.attach(part)


To fix the problem, I changed C:\Python31\Lib\email\encoders.py to use encodebytes instead of b64encode in order to get mail on Windows Vista to correctly interpret the attachment. This splits the base64 encoding into many lines of some fixed lenth.

I can achieve the same thing adding the attachment by hand with the following code:

    from email.mime.base import MIMEBase
    part = MIMEBase("application","pdf")
    part.add_header('Content-Transfer-Encoding', 'base64') 
    part.set_payload(str(base64.encodebytes(pdf),'ascii'))
    msg.attach(part)

Seems like I shouldn't need to know this much.

I'm new to Python and this is the first bug I have submitted, so if you need additional information, please let me know.
History
Date User Action Args
2010-07-19 03:05:01vunruhsetrecipients: + vunruh
2010-07-19 03:04:56vunruhsetmessageid: <1279508696.99.0.665109757672.issue9298@psf.upfronthosting.co.za>
2010-07-19 03:04:55vunruhlinkissue9298 messages
2010-07-19 03:04:54vunruhcreate