共用方式為


ExchangeUser.GetFreeBusy 方法 (Outlook)

會取得 String,表示從開始日期的 30 天內 ExchangeUser 的可與會狀態 (從指定日期的午夜十二點開始計算)。

語法

expressionGetFreeBusy( _Start_ , _MinPerChar_ , _CompleteFormat_ )

表達 代表 ExchangeUser 物件的 變數。

參數

名稱 必要/選用 資料類型 描述
Start 必要 Date 可與會的日期,從午夜十二點開始計算。
MinPerChar 必要 Long 會指定每一個時段的長度 (以分鐘為單位)。 預設值為 30 分鐘。
CompleteFormat 選用 Variant True 值表示空閒/忙碌字串中會傳回更精細資料粒度的忙碌時間。 False值表示只會傳回可用時間和忙碌時間之間的區別。

傳回值

String,表示 Exchange 使用者從開始日期起算的 30 天內的可用性,從指定日期的午夜開始。 String中的每個字元都是一個值,指出使用者是否 (0) 可用,並選擇性地將忙碌時間標示為暫訂 (1) 、不在辦公室 (3) ,還是其他 (2) 。

範例

下列 Visual Basic for Applications (VBA) 範例會使用 GetFreeBusy 方法,擷取指派給目前使用者之主管的空閒/忙碌資訊,其中每一個時段都表示 60 分鐘。 然後,此範例會使用該資訊來計算第一個可用期間發生的日期和時間,並在 [ 偵錯 ] 視窗中顯示該資訊。

Sub GetManagerOpenInterval() 
 Dim oManager As ExchangeUser 
 Dim oCurrentUser As ExchangeUser 
 Dim FreeBusy As String 
 Dim BusySlot As Long 
 Dim DateBusySlot As Date 
 Dim i As Long 
 Const SlotLength = 60 
 'Get ExchangeUser for CurrentUser 
 If Application.Session.CurrentUser.AddressEntry.Type = "EX" Then 
 Set oCurrentUser = _ 
 Application.Session.CurrentUser.AddressEntry.GetExchangeUser 
 'Get Manager 
 Set oManager = oManager.GetExchangeUserManager 
 If oManager Is Nothing Then 
 Exit Sub 
 End If 
 FreeBusy = oManager.GetFreeBusy(Now, SlotLength) 
 For i = 1 To Len(FreeBusy) 
 If CLng(Mid(FreeBusy, i, 1)) = 0 Then 
 'get the number of minutes into the day for free interval 
 BusySlot = (i - 1) * SlotLength 
 'get an actual date/time 
 DateBusySlot = DateAdd("n", BusySlot, Date) 
 'To refine this function, substitute actual 
 'workdays and working hours in date/time comparison 
 If TimeValue(DateBusySlot) >= TimeValue(#8:00:00 AM#) And _ 
 TimeValue(DateBusySlot) <= TimeValue(#5:00:00 PM#) And _ 
 Not (Weekday(DateBusySlot) = vbSaturday Or _ 
 Weekday(DateBusySlot) = vbSunday) Then 
 Debug.Print oManager.name & " first open interval:" & _ 
 vbCrLf & _ 
 Format$(DateBusySlot, "dddd, mmm d yyyy hh:mm AMPM") 
 Exit For 
 End If 
 End If 
 Next 
 End If 
End Sub

另請參閱

ExchangeUser 物件

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應