我正在尝试使用O365
发送电子邮件但是,如果不访问私有属性,我找不到设置收件人的方法。
from O365 import *
my_protocol = MSGraphProtocol(api_version='beta')
account = Account(
credentials=('id', 'id'),
protocol=my_protocol
)
if not account.is_authenticated: # will check if there is a token and has not expired
# ask for a login
account.authenticate(scopes=['mailbox', 'message_send'])
msg = Message(parent=account)
msg.body = 'Hi, foobar.'
msg.subject = 'Bar Foo'
msg.to = Recipient(address='foobar@outlook.com', name='lucas') # dont work
msg._Message__to._recipients = [Recipient(address='foobar@outlook.com', name='lucas')] # works but very bad way i supossed
msg.setRecipients(Recipient(address='foobar@outlook.com', name='lucas')) # some old tutorials used this, but dont work either
msg.send()
这肯定是一个非常愚蠢的问题,但是我从文档中读取了类,却找不到收件人的设置器。
谢谢!