ExchangeUser.GetFreeBusy (Outlook)

Obtains a String representing the availability of the ExchangeUser for a period of 30 days from the start date, beginning at midnight of the date specified.

GetFreeBusy (Start, MinPerChar, CompleteFormat)


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

Arguments

The following arguments are required:

Start (Date) - The date of availability, starting at midnight.

MinPerChar (Long) - Specifies the length of each time slot in minutes. Default is 30 minutes.

Optional arguments

The following argument is optional

CompleteFormat (Boolean) - A value of True indicates that a finer granularity of busy time is returned in the free/busy string. A value of False indicates that a distinction between only the available and busy times is returned.