You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Outlook GetFreeBusy方法调用报错(错误码0x80020009)求解决方案

解决Outlook中ExchangeUser.GetFreeBusy报错0x80020009的问题

针对你在Exchange+Office 365环境下调用GetFreeBusy时出现的错误码-2147352567(0x80020009),可尝试以下解决方案:

1. 检查空闲/忙碌发布与权限设置

  • 本地Outlook配置:打开「文件」→「选项」→「日历」→「日历权限」,确认“空闲/忙碌选项”已设置为至少「有限详细信息」,且发布天数足够覆盖你需要查询的范围(默认2个月)。
  • 管理员端配置:确认Exchange组织的空闲/忙碌共享策略未限制当前用户的信息访问权限。

2. 修正时间参数为UTC格式

GetFreeBusy要求起始时间为UTC时间,直接传入本地时间会导致解析错误,触发加载失败。修改代码如下:

VB.NET修正版

Dim strFreeBusy As String
Dim CurrentExchangeUser As ExchangeUser = CurrentNamespace.CurrentUser.AddressEntry.GetExchangeUser
' 将本地时间转换为UTC时间
Dim startUtc As DateTime = DateTime.UtcNow
strFreeBusy = CurrentExchangeUser.GetFreeBusy(startUtc, 60)

VBA修正版

Sub Test_1()
    Dim oCurrentUser As ExchangeUser
    Dim FreeBusy As String
    Const SlotLength = 60
    
    If Application.Session.CurrentUser.AddressEntry.Type = "EX" Then
        Set oCurrentUser = Application.Session.CurrentUser.AddressEntry.GetExchangeUser
    End If

    ' 转换本地时间为UTC时间
    Dim startUtc As Date
    startUtc = Application.Session.CurrentTimeZone.LocalTimeToUTC(Now)
    FreeBusy = oCurrentUser.GetFreeBusy(startUtc, SlotLength)
End Sub

3. 改用Exchange Web Services(EWS)获取空闲/忙碌信息

若Outlook对象模型的GetFreeBusy仍无法正常工作,直接调用EWS在O365环境下更稳定(需引用EWS Managed API):

Dim service As New ExchangeService(ExchangeVersion.Exchange2016)
service.UseDefaultCredentials = True
' 自动发现EWS地址
service.AutodiscoverUrl(CurrentNamespace.CurrentUser.AddressEntry.GetExchangeUser().PrimarySmtpAddress)

Dim attendee As New AttendeeInfo()
attendee.SmtpAddress = CurrentNamespace.CurrentUser.AddressEntry.GetExchangeUser().PrimarySmtpAddress
attendee.AttendeeType = MeetingAttendeeType.Organizer

Dim startUtc As DateTime = DateTime.UtcNow
Dim endUtc As DateTime = startUtc.AddDays(7) ' 查询未来7天
Dim options As New GetUserAvailabilityOptions()
options.RequestedFreeBusyView = FreeBusyViewType.FreeBusy

Dim results As GetUserAvailabilityResults = service.GetUserAvailability(
    New AttendeeInfo() {attendee}, 
    New TimeWindow(startUtc, endUtc), 
    options
)

' 遍历获取到的空闲/忙碌事件
For Each calendarEvent In results.AttendeesAvailability(0).CalendarEvents
    ' 处理事件信息,例如输出状态
    Debug.WriteLine($"时间段: {calendarEvent.StartTime} 至 {calendarEvent.EndTime}, 状态: {calendarEvent.FreeBusyStatus}")
Next

4. 修复Outlook缓存与联机状态

  • 清除OST缓存:关闭Outlook,删除%localappdata%\Microsoft\Outlook目录下的OST文件,重启Outlook后重新同步邮箱。
  • 确认联机状态:确保Outlook处于联机模式,未切换到脱机工作状态。

内容的提问来源于stack exchange,提问作者adi63

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 01:22:15