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中找到日曆文件夾。