Das Beispiel ermittelt, wieviele Termine an einem bestimmten Tag anliegen und berücksichtigt auch Serientermine. Der Rückgabewert liefert die Anzahl der gefundenen Termine, auf welche Sie über das optionale Argument oResult zugreifen können.
Public Function AppointmentsAtDay(ByVal dtDate As Date, _
Optional oResult As Outlook.Items _
) As Long
Dim oFld As Outlook.MAPIFolder
Dim oItems As Outlook.Items
Dim sFind As String
Dim obj As Object
Dim i As Long
Set oFld = Application.Session.GetDefaultFolder(olFolderCalendar)
Set oItems = oFld.Items
oItems.Sort "[Start]", False
oItems.IncludeRecurrences = True
sFind = Format(dtDate, "ddddd")
sFind = "[Start] <= " & _
Chr(34) & sFind & " 11:59 PM" & Chr(34) & _
" AND [End] > " & _
Chr(34) & sFind & " 12:00 AM" & Chr(34)
Set oResult = oItems.Restrict(sFind)
For Each obj In oResult
i = i + 1
Next
AppointmentsAtDay = i
End Function