Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Add-ins for Outlook (http://www.outlookbanter.com/add-ins-outlook/)
-   -   ItemAdd event fires more than once when adding a new appointment (http://www.outlookbanter.com/add-ins-outlook/75567-itemadd-event-fires-more-than.html)

Johan Machielse[_2_] July 22nd 08 08:56 AM

ItemAdd event fires more than once when adding a new appointment
 
Dear Reader,

I figured out that the ItemAdd event fires more than once when I add a new
appointment to the calendar in Outlook 2003! After a couple of ItemAdd events
one ItemChanged event is fired! It also seems that when there are more items
in the calendar, more ItemAdd events will be fired...

Does anyone know the cause of this strange behaviour and the solution?

Here's the code snippet which is executed in the OnStartupComplete() method
of my add-in:

Outlook.Application application =
(Microsoft.Office.Interop.Outlook.Application)appl icationObject;
Outlook.NameSpace mapiNamespace = application.GetNamespace("MAPI");
Outlook.MAPIFolder calendarFolder =
mapiNamespace.GetDefaultFolder(Outlook.OlDefaultFo lders.olFolderCalendar);

calendarFolder.Items.ItemAdd += new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemA ddEventHandler(Items_ItemAdd);
calendarFolder.Items.ItemChange += new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemC hangeEventHandler(Items_ItemChange);

Thank you in advance!

Johan Machielse
Avanade

Johan Machielse[_2_] July 22nd 08 12:11 PM

ItemAdd event fires more than once when adding a new appointment
 
Already solved; I added the handler to the event at two places!

"Johan Machielse" wrote:

Dear Reader,

I figured out that the ItemAdd event fires more than once when I add a new
appointment to the calendar in Outlook 2003! After a couple of ItemAdd events
one ItemChanged event is fired! It also seems that when there are more items
in the calendar, more ItemAdd events will be fired...

Does anyone know the cause of this strange behaviour and the solution?

Here's the code snippet which is executed in the OnStartupComplete() method
of my add-in:

Outlook.Application application =
(Microsoft.Office.Interop.Outlook.Application)appl icationObject;
Outlook.NameSpace mapiNamespace = application.GetNamespace("MAPI");
Outlook.MAPIFolder calendarFolder =
mapiNamespace.GetDefaultFolder(Outlook.OlDefaultFo lders.olFolderCalendar);

calendarFolder.Items.ItemAdd += new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemA ddEventHandler(Items_ItemAdd);
calendarFolder.Items.ItemChange += new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemC hangeEventHandler(Items_ItemChange);

Thank you in advance!

Johan Machielse
Avanade



All times are GMT +1. The time now is 12:32 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com