PC Review


Reply
Thread Tools Rate Thread

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

 
 
Chris van Kordenoordt
Guest
Posts: n/a
 
      11th Sep 2007
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();
}
 
Reply With Quote
 
 
 
 
Brian Tillman
Guest
Posts: n/a
 
      12th Sep 2007
Chris van Kordenoordt <(E-Mail Removed)> wrote:

> 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
--
Brian Tillman [MVP-Outlook]
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"microsoft office access" unknown error jcandamo Microsoft Access Queries 1 9th Jul 2009 09:01 PM
Receiving "Unknown" error opening DB tables (Office 2003 SP3) NCTech Microsoft Access 4 5th Jan 2008 02:18 PM
[C#/Office PIA]Outlook throws "Unknown error" when I insert calendarappointments Chris van Kordenoordt Microsoft Outlook Interoperability 0 11th Sep 2007 02:55 PM
"Outlook 2007" +"The Messenger interface has returned an unknown error" deleteriousone Microsoft Outlook 0 7th Feb 2007 12:48 AM
"The messaging interface has returned an unknown error" w/ Office Outlook 2003 Notes daveaprc@yahoo.com Microsoft Outlook 0 21st Jan 2005 12:31 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:45 AM.