已經在網上找過很多方法,但都不能成功.
利用graphapi及powershell,最終是這個效果
Get-MgUserMailFolderMessage : The request is trying to access a public folder in cloud which isn't supported.
Status: 403 (Forbidden)
ErrorCode: MailboxNotSupportedForRestApi
https://trycatchdebug.net/news/1299333/ps-graph-api-for-o365-calendar-events
再利用 Microsoft.Exchange.WebServices.dll, 也不成功.
365 與郵件有關的備份是比較麻煩,我是使用 Outlook 地端軟體設定某使用者的郵件帳號去做備份,公用的應該也可以,試看看公用資料夾附掛的帳號設定到 Outlook 地端軟體中
前提
Microsoft Graph API 和 Exchange Web Services (EWS) 不能直接存取 Office 365 公用資料夾行事曆,對於微軟的限制。公用資料夾行事曆仍是Exchange地端舊有架構,而 Graph API 只支援個人信箱、共享郵箱、Office 365 群組行事曆。
方法一.
如果只想從 PowerShell 或 Graph API 取得行事曆,可嘗試:
在 Outlook 中開啟公用資料夾行事曆
在「行事曆屬性」中,設定「共用權限」
將其「複製」到一個 共享郵箱 (Shared Mailbox),然後存取該共享行事曆
共享郵箱行事曆可以透過 Graph API 或 EWS 讀取
這樣就能繞過公用資料夾的限制
New-Mailbox -Name "SharedCalendar" -Shared
將行事曆從公用資料夾複製過去,透過手動拖拉或Power Automate同步
用Graph API讀取共享行事曆
GET https://graph.microsoft.com/v1.0/users/sharedcalendar@yourdomain.com/calendar/events
方法二.
透過Power Automate同步到SharePoint或Outlook Group
建立一個 SharePoint List,透過Power Automate
觸發條件:當 Outlook 行事曆事件新增時
動作:將資料寫入 SharePoint
透過 Microsoft Graph API 存取 SharePoint 行事曆
這樣就能用 REST API 讀取行事曆事件