Recurring Appointment issues

H

Ho-Yan Shum

I am experiencing a strange issue with recurring appointments. When you
create a recurring appointment, save it and close it.

Then open up the second occurence, close it and then re open it again (and
from now on each time you open the second or later occurences twice) you will
receive the following error:
"Cannot read one instance of this recurring appointment. Close any open
appointments and try again, or recreate the appointment."

This is cause by a line in the NewInpector event handler:
private void ThisApplication_Startup(object sender, System.EventArgs e)

void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector
Inspector)
{
Outlook.MailItem objMailItem = Inspector.CurrentItem as Outlook.MailItem;
}
 
K

Ken Slovak - [MVP - Outlook]

Your NewInspector code is assuming a MailItem, with no exception handling if
it's some other type of item. You should be checking for item.Class or
MessageClass.
 
K

Ken Slovak - [MVP - Outlook]

Yes, but I've found that to work best in fully managed code, not so great
with objects derived through the COM Interop. In any case I don't see that
line causing the type of problem you describe. Does the problem go away if
you comment out that line of code in NewInspector()?
 
H

Ho-Yan Shum

Yeah i've narrowed it to that line .. commenting it out eliminates the issue.

The steps i took to reproduce that error is:

1. Create a recurring appointment say starting today for 3 weeks
2. Double click the second occurrence of the appointments (so the one that
is scheduled for next week) and open it as an *occurrence*.
3. Close it and now try re-opening it. <- error here

It is occurring with Outlook 2003 SP2 - i can get exact build numbers tomorrow
 
K

Ken Slovak - [MVP - Outlook]

The only thing I can think of is possibly you're not releasing any handles
or references to that item so it's locked. Are you handling the
Inspector.Close() event and releasing all references there? You might even
have to try using Marshal.ReleaseComObject() on any references that are no
longer needed to release their RCW's.
 

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