Change Outlook appointment series having a starting date in the past

Viewed 59

maybe you've experienced this, too. When I get involved into a project that is already running the project lead or scrumm master forward me appointment series like daily stand-ups or similar and the series started long before the day I receive the invitation.

Let's asume the following as example:

  • The series starts on January, 11th 2021 (Monday) and re-occurs every week.
  • I receive the invitation in my inbox on March, 16th 2021 (Tuesday).

When I look into my calender I will see this appointment in January, February etc. although I didn't participate back then because I wasn't assigned. To keep my calender in a way that it shows what really happend I have to manually remove all those occurances.

What I want to archieve is this:

  • The invitation enters my inbox.
  • Application_NewMailEx is triggered and runs a piece of VBA code that checks for a series like the following.
    (...)
    If TypeName(objInboxObject) = "MeetingItem" Then
        Set objAppt = objInboxObject.GetAssociatedAppointment(False)
        If Not objAppt Is Nothing Then
            If objAppt.IsRecurring Then
                Set objRecurrPatt = objAppt.GetRecurrencePattern
                If Not objRecurrPatt Is Nothing Then
    (...)
  • That's easy to handle but now the tricky part that I cannot find a solution anywhere and I really hope one of you can help me.

How I can I find out the NEXT FUTURE occurance starting from TODAY (the date I received it)? In the example this would be March, 22nd 2021. Especially if the re-occurance pattern is more complex than in the example.

Then I would replace the start date of the series with this calculated date and save the MeetingItem. If I accept it in the normal Outlook window I will have one calendar entries in the future and none in the past.

1 Answers

Analyzing the RecurrencePattern object you can find the date of the next occurrence. Then you can use the RecurrencePattern.GetOccurrence method which returns a specific instance of the AppointmentItem object on the specified date. The GetOccurrence method generates an error if no appointment of that series exists on the specified date.

Related