Get AppointmentItem with GlobalAppointmentID using VBA?

43 views Asked by At

Based on [this][1] post, it seems I cannot set a variable to the appointmentItem by using the GlobalAppointmentID either by Restrict or Find methods. This post seems to be utilizing C#. Is it possible to do this another way through VBA? I continue to get an error "Condition is not valid". Is that telling me that I can't do it based on that condition or that I have syntax errors in my conditional statement?

Currently my code looks like this.

Public Function RescheduleAppointment(oNewDate As Date, ApptID As String) As Boolean
        Dim oAppt As Object
        oAppt = GetAppointment(ApptID)
        With oAppt
            .Edit
            .Start = oNewDate
            .Update
        End With
End Function
Private Function GetAppointment(OTLGAID As String) As AppointmentItem       
        Dim oAppt As Object
        Dim fdrCalendar As Object
        Dim oApptItems As Object
        'Initiate our refernce to the public folder in outlook.
        Set fdrCalendar = CreateConnection
        'Start creating our Appointment
        Set oApptItems = fdrCalendar.Items
        
        Set GetAppointment = oApptItems.Find("GlobalAppointmentID = '" & OTLGAID & "'")      
  
        Set oAppt = Nothing
        Set fdrCalendar = Nothing
        Set oApptItems = Nothing
    End Function

Another way around it is to check each item individually (inefficient). But if the above won't work, is there a way to call Find or Restrict using wildcards if my subject line also contains a unique value in each appointment? [1]: Get Outlook AppointmentItem using GlobalAppointmentID

1

There are 1 answers

1
Dmitry Streblechenko On

As mentioned at https://stackoverflow.com/a/70306955/332059, OOM will not let you search on binary properties, you'd need to use Extended MAPI (C++ or Delphi) or Redemption (any language, I am its author).

You can of course search on appointment subject using wildcards and @SQL syntax. The query below searches on PR_NORMALIZED_SUBJECT

oApptItems.Find("@SQL=""http://schemas.microsoft.com/mapi/proptag/0x0E1D001F"" LIKE 'Monthly%' ")