You changed one of the recurrences of this item

K

Kulvinder

Hi,

I am getting the following error when i am trying to fetch the
AppointmentItem associated with a RecurrenceException in its Exceptions
collection :

You changed one of the recurrences of this item, and this instance no longer
exists. Close any open items and try again.

My code is as below :

public partial class ThisAddIn
{

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Outlook.NameSpace mapi = Application.GetNamespace("MAPI");
mapi.Logon(missing, missing, missing, missing);
Outlook.MAPIFolder folder =
mapi.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);

try
{
foreach (Outlook.AppointmentItem item in folder.Items)
{
if (item.IsRecurring)
{
Outlook.RecurrencePattern pattern = item.GetRecurrencePattern();

foreach (Outlook.Exception exception in pattern.Exceptions)
{
Outlook.AppointmentItem exceptionItem = exception.AppointmentItem;
}
}
}

}
catch (Exception ex)
{
}

mapi.Logoff();
}

}

The error is coming in the line :
Outlook.AppointmentItem exceptionItem = exception.AppointmentItem;

Can anyone help me in this ?

Thanks
 
K

Ken Slovak - [MVP - Outlook]

Are you sure there are Exceptions? I'd suggest testing for Exceptions.Count
before trying to retrieve what may not be there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top