MIME Multipart Messages : Email : Network PYTHON examples


PYTHON examples » Network » Email »

 

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)

   
  



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Network
» Email