Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Interop / September 2007

Tip: Looking for answers? Try searching our database.

[C#/Office PIA]Outlook throws "Unknown error" when I insert calendar appointments

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris van Kordenoordt - 11 Sep 2007 14:56 GMT
I have created an application in C# with VS2005 that is supposed to get
appointments from a central database and insert them into the users
Outlook calendar. I use the Office 2003 PIA to accomplish this.

When I insert appointments in my testing environment everything works
just peachy. In the production environment however, which is quite a bit
slower, Outlook gives out after about 20-30 appointments with the error:
"Unknown error" and after that: "Can't open the item". This happens when
I try to delete some of the items in Outlook that are an exception to a
recurring appointment.

I suspect there is something that needs to be flushed or cleared after
inserting an appointment, but I can't seem to find a suitable solution.
The code I use(simplified -- only the outlook parts are shown) is shown
below. Appointment is a custom object that contains the properties of my
appointments.

My question: Is this a good way to remove the exceptions from a
recurring appointment in Outlook or is there a better way to do this? Am
I using the PIA the right way?

If there is any additional information needed that I haven't yet
provided, please ask.

Thanks in advance, this has been bugging me for days.

Chris

-------
        private void RemoveExceptions(Appointment appointment)
        {
            //Set Outlook API parameters
            Outlook._Application outlookApp = (Outlook._Application)new
Outlook.Application();
            Outlook.NameSpace mapiNamespace;
            Outlook.MAPIFolder olCalendar;
            mapiNamespace = outlookApp.GetNamespace("MAPI");
            olCalendar =
mapiNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);

       //Get the appointment I want to edit from Outlook
            Outlook._AppointmentItem olAppointment =
(Outlook._AppointmentItem)mapiNamespace.GetItemFromID(appointment.OutlookId,
olCalendar.StoreID);

            mapiNamespace.Logon(null, null, null, null);

            for (//do some loop)
            {
                    //Get the item that is an exception and delete it
           try
                    {
                        Outlook._AppointmentItem item =
olAppointment.GetRecurrencePattern().GetOccurrence(//somedate);
                        if (item != null)
                            item.Delete();
                    }
                    catch (Exception){}
                }
            }
//Save and close the appointment
olAppointment.Close(Microsoft.Office.Interop.Outlook.OlInspectorClose.olSave);
            mapiNamespace.Logoff();
        }
Brian Tillman - 12 Sep 2007 03:48 GMT
> I have created an application in C# with VS2005 that is supposed to
> get appointments from a central database and insert them into the
> users Outlook calendar. I use the Office 2003 PIA to accomplish this.

You may get better advice in the programming groups:
microsoft.public.outlook.program_addins
microsoft.public.outlook.program_vba
Signature

Brian Tillman [MVP-Outlook]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.