2013年1月30日 星期三

[Python] Sending Plain-text email with outlook



# -*- coding: utf-8 -*-
#
# note: can't send HTML email
#
import win32com.client
olMailItem = 0x0
obj = win32com.client.Dispatch("Outlook.Application")
newMail = obj.CreateItem(olMailItem)
newMail.Subject = "I AM SUBJECT!!"
newMail.Body = "I AM IN THE BODY\nSO AM I!!!"
newMail.To = "victor_hsu@compalcomm.com"
newMail.CC = "victor_hsu@compalcomm.com"
#newMail.BCC = "address"
#attachment1 = "Path to attachment no. 1"
#attachment2 = "Path to attachment no. 2"
#newMail.Attachments.Add(attachment1)
#newMail.Attachments.Add(attachment2)
#newMail.display()
newMail.Send()

沒有留言: