I am fetching all emails within a timeframe from MSOutlook to populate a sheet of Excel.
Using Items.Restrict( filterstring ) to constrain the results to between two datetime stamps.
This works fine for intervals like 6/14/2024 23:59 and 6/15/2024 23:59 (daylong) returning the correct count of Outlook incomings ( emails, meeting invites, reports etc ) but not for intervals like 6/15/2024 4:50 and 6/15/2024 23:59.
Returning 0 results ( incorrectly: as validated against Outlook )
'Has the nescessary Outlook variable declarations and references. DateTime vars in bold
restrictfilter = "[ReceivedTime] > '" & Format(CStr(**strtT**), "M/D/YYYY h:n") & "' AND [ReceivedTime] <= '" & Format(CStr(**EndT**), "M/D/YYYY h:n") & "'"
Set olItems = olFolder.Items.Restrict(restrictfilter)
allitemscount = olItems.Count
Kindly advice on some correction or any other approach.
Thanks,
Somdeb