Python - Send Email From Windows Using CDO
Python - Send Email From Windows Using CDO
Submitted by corey@goldb.org (Corey Goldberg) on Wed, 11/02/2009 - 20:37.Here is quick script showing how to use Python to send email from Windows.
This approach uses the Python For Windows Extensions to access Outlook/Exchange with CDO (Collaboration Data Objects).
#!/usr/bin/env python
# Corey Goldberg
from win32com.client import Dispatch
session = Dispatch('MAPI.session')
session.Logon('','',0,1,0,0,'exchange.foo.com\nUserName');
msg = session.Outbox.Messages.Add('Hello', 'This is a test')
msg.Recipients.Add('Corey', 'SMTP:corey@foo.com')
msg.Send()
session.Logoff()
