如何使用 Python 中的 win32com.client 模块向多个客户端或群组发送邮件?

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

我正在尝试使用 Python 中的 win32com.client 模块 发送邮件。但无法提出适当的文档来支持多个收件人或群组发送消息。 有人可以建议吗。 我有特定要求只能使用 Outlook 应用程序。

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 = "who_to_send_to@example.com"
#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()

系统配置详情:

非常感谢

您需要为每个地址调用 newMail.Recipients.Add(它是 returns Recipient 对象,并且您可以将其 Type 属性 设置为 olTo / olCC / olBCC 如有必要 - 默认为 olTo) 或者您可以将 newMail.To / CC /BCC 属性设置为的列表 ”;”分隔的名称或地址。