对不起,我不只是看到我做错了什么(很可能很多)。我要做的就是阅读公共日历的事件。我试图关注有关使用公用文件夹的讨论,但这对新手来说有点混乱。在 OpenSuse 15.0 上使用 python 2.7.x
from exchangelib.folders import Calendar
from exchangelib import Credentials, Account, CalendarItem, UTC_NOW
import datetime
account = Account(...)
account.public_folders_root.refresh()
start = UTC_NOW() - datetime.timedelta(days=7)
print account.public_folders_root.tree() #this works
x = account.public_folders_root
specificFolder = [item for item in x.walk().get_folders() if item.name == "OC Appointment Calendar"]
leg_folder = Calendar(folder_id = specificFolder[0].id, changekey = specificFolder[0].changekey)
for i in leg_folder.view(start=start, end=start + datetime.timedelta(days=14)):
print i
testexchange.py", line 15, in <module>
for i in leg_folder.view(start=start, end=start + datetime.timedelta(days=14)):
File "/usr/lib/python2.7/site-packages/exchangelib/folders.py", line 957, in view
return FolderCollection(account=self.root.account, folders=[self]).view(*args, **kwargs)
AttributeError: 'NoneType' object has no attribute 'account