send email

Rudy Schockaert rudy.schockaert at pandora.be
Thu Sep 25 14:25:18 EDT 2003


Alberto Vera wrote:
> Hello:
>  
> Could you tell me How I can send an email using WIN2000? What do I need?
>  
> Thanks

Why don't you try the following:

##### start of script #######
from email.MIMEText import MIMEText
import smtplib

myVar = 'result of previous action'

body='''this text will become the body of the message
Using triple-quotes you can span it easily over multiple lines.
You can also add the value of variables in it: %s .
This can come in handy if you want to mail
the result of an action''' % (myVar)

msg = MIMEText(body)
 From = "myApp at myServer.net"
To = "whoever.is.interested at mydomain.org"
CC = "someone.else at mydomain.org"
msg['From'] = From
msg['To'] = To
msg['Cc'] = CC
msg['Subject'] = "Don't leave me empty please"

server = smtplib.SMTP("mailserver.mydomain.org")
server.sendmail(From,[To,CC],msg.as_string())
server.quit

###### end of script #####





More information about the Python-list mailing list