How to send body and attachements in an email message?

srinivasan srinivas sri_annauni at yahoo.co.in
Wed Dec 3 11:40:30 CET 2008


HI,
I would like to send an email message with body-content 'test' and an attachment.
The snippet i used is:
outer = email.mime.multipart.MIMEMultipart()
msg1 = email.mime.text.MIMEText(<filename1>, _subtype = 'text')
msg1.add_header('Content-Disposition', 'attachment')
outer.attach(msg1)

body = email.mime.text.MIMEText(<filename1>, _subtype = 'text')
outer.attach(body)

smtp_client = smtplib.SMTP()
smtp_client.connect()
smtp_client.sendmail(<sender>, <recipient>, outer.as_string())
smtp_client.close()

If i do like above, i am receiving the body also as an attachment. How to set body to Multipart email message?

Thanks,
Srini


      Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/



More information about the Python-list mailing list