module email

Sergey Dorofeev sergey at fidoman.ru
Wed Jan 24 17:02:28 CET 2007


Hello.

Why does not work?

--------------
import email.message
import smtplib
import time

m=email.message.Message()
m.set_type("multipart/mixed")
m["From"]="Sergey Dorofeev <sergey at prodo.ru>"
m["To"]="Sergey Dorofeev <sergey at prodo.ru>"
m["Date"]=time.asctime()
m["Subject"]="test"


p1=email.message.Message()
p1.set_payload("message text", "us-ascii")
m.attach(p1)

p2=email.message.Message()
p2.set_payload("message text 2", "us-ascii")
m.attach(p2)

del p1,p2

print m.as_string()
print "*"*50


x=email.message.Message()
x.set_type("multipart/mixed")
x["From"]="Sergey Dorofeev <sergey at prodo.ru>"
x["To"]="Sergey Dorofeev <sergey at prodo.ru>"
x["Date"]=time.asctime()
x["Subject"]="test"

p1=email.message.Message()
p1.set_payload("message text !", "us-ascii")
print p1
x.attach(p1)


p2=email.message.Message()
p2.set_type("message/rfc822")
p2.set_payload(m)
print p2
x.attach(p2)


print "*"*50
print x.as_string()

--------------

I'm using Python 2.5 





More information about the Python-list mailing list