Outlook .Restrict method doesn't filter calendar meetings by date correctly

When trying to extract future calendar events from Outlook, the method Items.Restrict is not working as expected.

If the filter is not applied, it returns more than 70 results, older and future events. When the filter for future events is applied, it returns around 20 results, most of them, future events, but also some old ones.

The Restrict filter is partially working, but I cannot understand why is not filtering those few old events.

Dim oOutlook            As Object
Dim oMAPI               As Object
Dim oAppointments       As Object
Dim oFilteredAppointments As Object
Dim oAppointmentItem    As Object
Dim sFilter             As String
Const olFolderCalendar = 9

Set oOutlook = GetObject(, "Outlook.Application")
Set oMAPI = oOutlook.GetNamespace("MAPI")
Set oAppointments = oMAPI.GetDefaultFolder(olFolderCalendar)

sFilter = "[Start]>'" & Date & "'"
Debug.Print sFilter
Set oFilteredAppointments = oAppointments.Items.Restrict(sFilter)

For Each oAppointmentItem In oFilteredAppointments
    Debug.Print oAppointmentItem.Start
Next

To show some evidence of the filter and the results I'm getting:

Immediate window showing wrong results

Any idea on why this is happening and how I can fix it?



Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)