[Tutor] pdf file as attachment
Kent Johnson
kent_johnson at skillsoft.com
Mon Aug 23 22:27:46 CEST 2004
I think you need to send the pdf with the mime type 'application/pdf'
instead of text. Here is an example that may help you:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/86674
Alternatively you might write your own MIMEPdf class by modifying MIMEText
- if you look at Python/Lib/email/MIMEText.py there is not much there to
modify.
Kent
At 04:18 PM 8/22/2004 -0400, r2b2 wrote:
>looking for a little help sending a PDF file as file attachment to an
>email message. The below code works with a text tpye doc but wandering how
>i can send a PDF file.
>(newbie)
>thanks
>
>
>
>from email.MIMEMultipart import MIMEMultipart
>from email.MIMEText import MIMEText
>from email.MIMEImage import MIMEImage
>#from email.MIMEMultipart import MIMEMultipart
>fp=open("c:\document.pdf","rb")
>msg=MIMEMultipart("this is a test")
>body=MIMEText(fp.read())
>fp.close()
>msg.attach(body)
>
>
>import smtplib
>s=smtplib.SMTP('mail.com')
>#s.connect(host=mail..com,port=25)
>s.sendmail('mail at aol.com',msg.as_string())
>s.close()
>
>
>
>
>_______________________________________________
>No banners. No pop-ups. No kidding.
>Make My Way your home on the Web - http://www.myway.com
>_______________________________________________
>Tutor maillist - Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list