C.Corvax
C.Corvax

Reputation: 43

Get AppointmentItem with GlobalAppointmentID using VBA

Based on this post, it seems I cannot set a variable to the appointmentItem by using GlobalAppointmentID, either by the Restrict or Find methods.

This post seems to be utilizing C#. Is it possible to do this another way through VBA?

I get an error when trying to below code: Condition is not valid

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  = Nothing
    Set oApptItems = Nothing
    
End Function

Another way around it is to check each item individually (inefficient).

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?

Upvotes: 0

Views: 125

Answers (1)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66341

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%' ")

Upvotes: 0

Related Questions