Chandra Shekhar
Chandra Shekhar

Reputation: 617

How to Send the mail to multiple clients or groups using win32com.client Module in Python?

I am trying to send the mail using win32com.client Module in Python. But could not come up with the proper documentation to support multiple recipients or groups to send the message. Could someone please suggest. I have specific requirement to work with only outlook application.

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 = "[email protected]"
#newMail.CC = "moreaddresses here"
#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()

System configuration details:

Upvotes: 0

Views: 923

Answers (1)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66276

You need to either call newMail.Recipients.Add for each address (it returns Recipient object, and you can set its Type property to olTo / olCC / olBCC if necessary - it defaults to olTo) or you can set newMail.To / CC /BCC properties to a list of ";" separated names or address.

Upvotes: 1

Related Questions