Message110710
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. |
|
Date |
User |
Action |
Args |
2010-07-19 03:05:01 | vunruh | set | recipients:
+ vunruh |
2010-07-19 03:04:56 | vunruh | set | messageid: <1279508696.99.0.665109757672.issue9298@psf.upfronthosting.co.za> |
2010-07-19 03:04:55 | vunruh | link | issue9298 messages |
2010-07-19 03:04:54 | vunruh | create | |
|