Python 3.x 使用Python和O365向多个收件人发送电子邮件

Python 3.x 使用Python和O365向多个收件人发送电子邮件,python-3.x,office365,Python 3.x,Office365,我需要向多个收件人发送电子邮件,但只有一个收件人收到。下面是我正在使用的代码 from O365 import Message o365_auth = ('user.com', 'Pwd') m = Message(auth=o365_auth) m.setRecipients('user1.com','user2.com') m.setSubject('abc found.') m.setBody('''abc found.' Regards Shashi S Singh''') m.se

我需要向多个收件人发送电子邮件,但只有一个收件人收到。下面是我正在使用的代码

from O365 import Message

o365_auth = ('user.com', 'Pwd')
m = Message(auth=o365_auth)
m.setRecipients('user1.com','user2.com')
m.setSubject('abc found.')
m.setBody('''abc found.'

Regards
Shashi S Singh''')
m.sendMessage()
但是,一旦触发,它将只向第一个收件人发送电子邮件,而预期将向两个收件人发送电子邮件

from O365 import Message

recipients=['user1.com','user2.com']#create a list of recipients
o365_auth = ('user.com', 'Pwd')
m = Message(auth=o365_auth)
m.setRecipients(recipients)#use the list created
m.setSubject('abc found.')
m.setBody('''abc found.'

Regards
Shashi S Singh''')
m.sendMessage()

创建一个列表并使用相同的方法完成了任务。

如果将电子邮件设置为一个字符串,是否有效
m.setRecipients('user1.com,user2.com')
谢谢ode2k,但我已经尝试过了,但没有成功。你知道如何使用“cc”字段向收件人发送消息吗?@Milton
m.addRecipient('code')bob@loblaw.com,r_type=“Cc”)
m.addRecipient('bob@loblaw.com,r_type=“Bcc”)
应该这样做