为什么我无法连接到Exchange?

问题描述

无法连接到Exchange:401客户端错误:未经授权的网址:https://outlook.office365.com/EWS/Exchange.asmx

from pyexchange import Exchange2010Service,ExchangeNTLMAuthConnection
from pytz import timezone
from datetime import datetime
URL = u'https://outlook.office365.com/EWS/Exchange.asmx'
USERNAME = u'user@abc.com'
PASSWORD = u"password"

# Set up the connection to Exchange
connection = ExchangeNTLMAuthConnection(url=URL,username=USERNAME,password=PASSWORD)

service = Exchange2010Service(connection)

# List all events from date to date
calendar_list = service.calendar().list_events(
    start=timezone('Europe/Amsterdam').localize(datetime(2020,7,1)),end=timezone('Europe/Amsterdam').localize(datetime(2020,10,30)),details=True
)

for event in calendar_list.events:
    print("{start} ------ {stop} ------ {subject}".format(
        start=event.start,stop=event.end,subject=event.subject
    ))

感谢您的帮助

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)