none
Problem reading newly created Outlook exceptions RRS feed

  • Question

  • We get:
     0x000000000c583948 { "You changed one of the recurrences of this item, and this instance no longer exists. Close any open items and try again."}
    when accessing a newly created exception 

    We create a recurring appointment and drag one of the occurrences to a new time.When we execute the code below and look at Appointment.RecurrenceState of the 
    newly created exception we get the above error.

        Private Sub ReadExceptions(ByVal problem As Boolean)
            Dim CalendarFolder As Object, MyApplication As Object, OutlookNameSpace As Object
            Dim objItems As Outlook.Items, Items As Outlook.Items

            Dim startTime, endTime As DateTime
            startTime = DateTime.Now
            endTime = DateTime.Now
            startTime = startTime.AddMonths(-1)

            Dim StartDate As DateTime = New DateTime(startTime.Year, startTime.Month, startTime.Day, 0, 0, 0)
            Dim EndDate As DateTime = New DateTime(endTime.Year, endTime.Month, endTime.Day, 23, 59, 0)

            Dim Criteria As String = "[Start] >= '" & StartDate.ToString("MMMM dd yyyy HH:mm") & "' AND [Start] <= '" & EndDate.ToString("MMMM dd yyyy HH:mm") & "'"   'Works when dates set to US

            MyApplication = CreateObject("Outlook.Application")
            OutlookNameSpace = MyApplication.GetNameSpace("MAPI")
            CalendarFolder = OutlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar)

            Items = CalendarFolder.Items
            Items.Sort("Start", False)
            Items.IncludeRecurrences = True
            objItems = Items.Restrict(Criteria)
            For Each Appointment In objItems
                Try
                    If Appointment.AllDayEvent Or Appointment.RecurrenceState = Microsoft.Office.Interop.Outlook.OlRecurrenceState.olApptMaster Then
                    Else
                        nItemCount = nItemCount + 1
                    End If
                Catch ex As Exception
                    problem = True
                    System.Windows.Forms.MessageBox.Show("Error")
                End Try
            Next
        End Sub


    If we then re-open the series we no longer get the exception.

    Trying to read exceptions using Pattern.exception returns nothing.

     

    This is a real problem for us. Is there a way to stop this happening without re-opening the series? Can we, perhaps, re-initialise the series from code?

             
    Thursday, August 22, 2013 3:10 PM

Answers

  • Outlook really likes to cache appointments. For other items, releasing the item would usually remove it from the cache, but for the appointments at the very least you need to switch to a different folder.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by BorisCousins Thursday, August 22, 2013 8:06 PM
    Thursday, August 22, 2013 4:43 PM

All replies

  • Outlook really likes to cache appointments. For other items, releasing the item would usually remove it from the cache, but for the appointments at the very least you need to switch to a different folder.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by BorisCousins Thursday, August 22, 2013 8:06 PM
    Thursday, August 22, 2013 4:43 PM
  • Thanks Dmitry,

    I thought I had released everything but I think you are absolutely correct - something hasn't been released when I create the appointment. I just need to find out where.

    Boris

    Thursday, August 22, 2013 8:06 PM
  • Even if you do release everything, Outlook might still hold a reference to an appointment...

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, August 22, 2013 8:08 PM