New submission from Vance Unruh <[email protected]>:
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.
----------
components: Library (Lib)
messages: 110710
nosy: vunruh
priority: normal
severity: normal
status: open
title: binary email attachment issue with base64 encoding
versions: Python 3.1
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue9298>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com