1

我目前使用exchangelib连接到Office365 EWS。我目前的情况是,我想访问我们会议室的日历。当我点击Outlook中的“添加房间”选项时,他们的日历就会显示出来。当我将它们添加到日历视图的“其他日历”部分时,它们也会出现。访问exchangelib中的“其他日历”

当我尝试使用会议室的电子邮件地址作为该帐户,然后检查日历,我收到以下错误:

exchangelib.errors.ErrorFolderNotFound: No useable default Calendar folders 

所以我想,我只想通过访问日历我登录,而不是;就好像我正在查看Outlook中的其他日历部分一样。问题是,我似乎无法弄清楚如何访问这些日历。我可以访问我自己没有问题。

当我查看EWS的C#实现时,有一种搜索文件夹的方法,这就是您可以在其中找到其他日历的位置。我在exchangelib中看不到任何此类内容。

举个例子:

credentials = Credentials(username='My email address', password='My password') 
config = Configuration(credentials=credentials, server='outlook.office365.com', has_ssl=True) 
email = # My e-mail address (I also attempted with the room's e-mail address) 

account = Account(primary_smtp_address=email, credentials=credentials, 
        autodiscover=False, config=config) 

for f in account.folders: 
    print f 

结果:

<class 'exchangelib.folders.Calendar'> 
<class 'exchangelib.folders.Contacts'> 
<class 'exchangelib.folders.Tasks'> 
<class 'exchangelib.folders.Messages'> 
<class 'exchangelib.folders.Folder'> 

的 '日历' 选项不能重复,但 '文件夹' 选项。

for f in account.folders[Folder]: 
    print f 

结果:

Folder (Conversation Action Settings) 
Folder (Conversation History) 
Folder (Files) 
Folder (Journal) 
Folder (Notes) 
Folder (Quick Step Settings) 
Folder (RSS Feeds) 
Folder (Social Activity Notifications) 
Folder (Yammer Root) 

这些选项没有人可以给我什么我要找的。

任何援助将不胜感激!

预先感谢您

编辑

我已经找到了account.root.get_folders()魔力。我现在可以看到一个非常大的文件夹列表。但是,我仍然没有看到其他日历似乎可用的内容。

我一直在阅读有关别人是用C#解决方案和整个这个线程传来:

EWS - Access All Shared Calendars

看来他们有某种形式的搜索过滤器,但我无法找到它在exchangelib库内。

随后我发现另一个线索:

https://social.msdn.microsoft.com/Forums/en-US/2bfe798e-501f-421e-9a9a-76ae7eaf57c8/other-calendars-in-ews?forum=exchangesvrdevelopment

这其中谈到了其他日历是怎样的日历对象下的文件夹。但是,当我查询account.calendar.get_folders()我回来0结果。

回答

1

No useable default Calendar folders错误表示exchangelib在该帐户的文件夹中找不到默认日历文件夹。这可能有多种原因。您仍然可以在Account.folders中找到日历文件夹。