I have a Calendar in a Public Folder There are approximately 15000 appointments in the calendar over a period of several years I have used OutlookSpy to get the EntryId for the Calendar Using an example from an Outlook Programming book
Private Sub GetAppointmentsForDate(dteDate As Date)
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim colCal As Outlook.Items
Dim strFind As String
Dim colMyAppts As Outlook.Items
Dim objAppt As Outlook.AppointmentItem
Set objApp = CreateObject("Outlook.Application")
Set objNS = Application.GetNamespace("MAPI")
Set colCal = objNS.GetFolderFromID("{the Entry ID from OutlookSpy}").Items
colCal.Sort "[Start]"
colCal.IncludeRecurrences = True
Set colMyAppts = Nothing
strFind = "[Start] >= " & DoubleQuote(Format(dteDate, "dd mmm yyyy") & " 12:00 AM") & " AND [Start] < " & DoubleQuote(Format(dteDate + 1, "dd mmm yyyy") & " 12:00 AM")
Set colMyAppts = colCal.Restrict(strFind)
For Each objAppt In colMyAppts
Debug.Print objAppt.Start & vbTab & objAppt.Subject
Next
'clean up the objects used here
End Sub
I'd like to be able to do this using MAPI directly (CDO 1.21) The filtering sometimes takes up to 2 minutes, and I'd like to get this down to a few seconds.
If anyone has any idea's or improvements to the example code, I'd appreciate your input. [Any flavour of VB welcome]