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 / Programming Add-Ins / May 2008

Tip: Looking for answers? Try searching our database.

Registering events on calendar items on startup

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Manish - 06 May 2008 16:54 GMT
I need to register for ItemEvents_10_BeforeDeleteEventHandler,
ItemEvents_10_PropertyChangeEventHandler on any Calendar Event that is
processed by my addin.  For any calendar event handled by my addin, I
mainatin the Outlook Id in a database, and also set a user-property on the
outlook appt item.

I know of 2 ways to register for these event handlers for all my calendar
items.  Question is which one is better.  Can you please provide some insight.

1) On startup complete, I get a list of all calendar folders and iterate
through every item in each of the folders looking for either my user-property
being set, or if the outlook id matches ones in my database.  For each such
item, I register the event handlers.  Problem I see here is that the add-in
might take too long to load.  Im not sure how many months/years of calendar
appts are returned if I called GetDefaultFolder.

2) I register for ExplorerEvents_10_BeforeFolderSwitchEventHandler on all
acitve explorers, and if the ToFolder is of type olAppointmentItem, then I
register for this.Application.ActiveExplorer().SelectionChange += new
Outlook.ExplorerEvents_10_SelectionChangeEventHandler.  Then when the user
selects an appointment Item, my callback can check if my user property is
set, and if so register for the property-change and delete event handlers.  
problem with this approach is that my callback is being called on every
folder change and also on every item selection in an appointment folder.

Any suggestions on which approach is better?   Thanks in advance.

- Manish
Ken Slovak - [MVP - Outlook] - 07 May 2008 00:14 GMT
Both of the events you mention are Item level events, best handled by
instantiating an Item and Inspector in the Inspectors.NewInspector() event
handler. You check the item type in that handler for
Inspector.CurrentItem.Class (use reflection for that) and if it's an
appointment or meeting item (whatever you want to handle) instantiate your
Item and Inspector objects.

Most of us use lists of Inspector wrapper classes to handle multiple open
items. In the wrapper class you instantiate the item event handlers you
want. That's a much more isolated approach, each item in its own Inspector
wrapper class and it keeps all the items in scope.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

>I need to register for ItemEvents_10_BeforeDeleteEventHandler,
> ItemEvents_10_PropertyChangeEventHandler on any Calendar Event that is
[quoted text clipped - 29 lines]
>
> - Manish
Manish - 12 May 2008 17:15 GMT
Hi Ken,

Thanks for the response.  I am using your suggested approach of having a
list of inspector wrappers.  I used the TraveAgency sample from MSDN to
structure the code of my add-in.  Although I do register for the events on
the outlook item in the inspector class, thats not good enough because the
user can modify the start-time, end-time, subject using the explorer view by
dragging and dropping the appointment or deleting it.  I need to be notified
when this happens.  So doing it at the inspector wrapper level is not
sufficient.  Which is why I have to either register events for all of my
add-in's managed calender appointments or I have to register the events
during item selection.
Is my approach correct?

> Both of the events you mention are Item level events, best handhled by
> instantiating an Item and Inspector in the Inspectors.NewInspector() event
[quoted text clipped - 41 lines]
> >
> > - Manish
Ken Slovak - [MVP - Outlook] - 12 May 2008 18:41 GMT
In that case registering for events you want for all items in the Selection
collection would be the way to go to handle changes from in-cell editing.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm

> Hi Ken,
>
[quoted text clipped - 11 lines]
> during item selection.
> Is my approach correct?
Manish - 12 May 2008 19:31 GMT
Thank you.

> In that case registering for events you want for all items in the Selection
> collection would be the way to go to handle changes from in-cell editing.
[quoted text clipped - 14 lines]
> > during item selection.
> > Is my approach correct?

Rate this thread:






 
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.