none
Outlook 2013 VBA Event for recurring appointments RRS feed

  • Question

  • Hello,

    I have VBA code that copies new Calendar entries to a secondary calendar. For recurring meetings it only copies the 1st meeting to the secondary calendar. Is there an Outlook VBA event that occurs whenever a Recurring appointment is created and/or edited? I have done some searching on the Internet but haven't found any answers.


    Adrian Hernandez

    Friday, February 20, 2015 2:12 PM

Answers

  • Hello Adrian,

    The Outlook object model doesn't provide such events. Instead, make sure that the RecurrencePattern object is set properly on the copied appointment item. The GetRecurrencePattern method of the AppointmentItem class returns a RecurrencePattern object that represents the recurrence attributes of an appointment. If there is no existing recurrence pattern, a new empty RecurrencePattern object is returned.

    The IsRecurring property of the AppointmentItem class is based on the GetRecurrencePattern method. When the GetRecurrencePattern method is used with an AppointmentItem object, this property is set to True.

    Be aware, when you work with recurring appointment items, you should release any prior references, obtain new references to the recurring appointment item before you access or modify the item, and release these references as soon as you are finished and have saved the changes. This practice applies to the recurringAppointmentItem object, and any Exception or RecurrencePattern object. To release a reference in Visual Basic for Applications (VBA) or Visual Basic, set that existing object to Nothing. In C#, explicitly release the memory for that object. For a code example, see the topic for the AppointmentItem object.

    Note that even after you release your reference and attempt to obtain a new reference, if there is still an active reference, held by another add-in or Outlook, to one of the above objects, your new reference will still point to an out-of-date copy of the object. Therefore, it is important that you release your references as soon as you are finished with the recurring appointment.

    Friday, February 20, 2015 2:22 PM

All replies

  • Hello Adrian,

    The Outlook object model doesn't provide such events. Instead, make sure that the RecurrencePattern object is set properly on the copied appointment item. The GetRecurrencePattern method of the AppointmentItem class returns a RecurrencePattern object that represents the recurrence attributes of an appointment. If there is no existing recurrence pattern, a new empty RecurrencePattern object is returned.

    The IsRecurring property of the AppointmentItem class is based on the GetRecurrencePattern method. When the GetRecurrencePattern method is used with an AppointmentItem object, this property is set to True.

    Be aware, when you work with recurring appointment items, you should release any prior references, obtain new references to the recurring appointment item before you access or modify the item, and release these references as soon as you are finished and have saved the changes. This practice applies to the recurringAppointmentItem object, and any Exception or RecurrencePattern object. To release a reference in Visual Basic for Applications (VBA) or Visual Basic, set that existing object to Nothing. In C#, explicitly release the memory for that object. For a code example, see the topic for the AppointmentItem object.

    Note that even after you release your reference and attempt to obtain a new reference, if there is still an active reference, held by another add-in or Outlook, to one of the above objects, your new reference will still point to an out-of-date copy of the object. Therefore, it is important that you release your references as soon as you are finished with the recurring appointment.

    Friday, February 20, 2015 2:22 PM
  • OK. Is there anyway tha I could just simply copy the exact same object (the new recurring appointment) to the other calendar? Isn't the object suppose to contain all the properties so when it is copied everything is copied?

    Adrian Hernandez

    Monday, February 23, 2015 4:25 PM
  • Hi Adrian,

    Theoretically the Copy method does the job as it should.

    Note, the object may also contain user properties which can be not defined in the target folder. In that case  you need to copy/set them manually. The same you need to do for the recurrence pattern.

    Monday, February 23, 2015 5:46 PM