How to send body and attachements in an email message?

  • Thread starter srinivasan srinivas
  • Start date
S

srinivasan srinivas

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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top