MIME Multipart Messages : Email « Network « Python






MIME Multipart Messages

 

#!/usr/bin/python
from email.MIMEMultipart import MIMEMultipart
import os
import sys

filename = sys.argv[1]

msg = MIMEMultipart()
msg['From'] = 'Me <me@example.com>'
msg['To'] = 'You <you@example.com>'
msg['Subject'] = 'Your picture'

from email.MIMEText import MIMEText
text = MIMEText("Here's that picture I took of you.")
msg.attach(text)

from email.MIMEImage import MIMEImage
image = MIMEImage(open(filename).read(), name=os.path.split(filename)[1])
msg.attach(image)

   
  








Related examples in the same category

1.Print out email message from your email box
2.Send email to two receivers
3.Get email message mymailbox.msg file
4.Sending Some E-Mail
5.Send an email
6.Login to POP3 server and retrieve information
7.Sending Mail over an SMTP Connection