gpt4 book ai didi

python - 我无法使用 Exchangelib 读取交换日历

转载 作者:行者123 更新时间:2023-12-01 08:16:22 28 4
gpt4 key购买 nike

很抱歉,我不仅看到自己做错了什么(很可能很多)。我想做的就是阅读公共(public)日历上的事件。我尝试关注有关使用公共(public)文件夹的讨论,但这对于新手来说有点令人困惑。在 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

最佳答案

事实证明,我离这个目标并不遥远。但以下是允许访问约会的代码更改。

#specificFolder = [item for item in x.walk().get_folders() if item.name == "OC Appointment Calendar"]
# I was close in above but a better way to find the folder I was looking for is:
specificFolder = list(account.public_folders_root.glob('**/OC Appointment Calendar'))[0]
# Now I can use view()
for item in specificFolder.view(start=start, end=start + datetime.timedelta(days=14)):
# item now has all the available data
print item.mime_content

关于python - 我无法使用 Exchangelib 读取交换日历,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54964414/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com