Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   How to Unregister events (http://www.outlookbanter.com/outlook-vba/27802-how-unregister-events.html)

Virda September 22nd 06 12:53 PM

How to Unregister events
 

Hello List,

I want to unregister some events,
When execuation code reached to the line

tems.ItemAdd -= new
Outlook.ItemsEvents_ItemAddEventHandler(this.Items _ItemAdd);

it raises exception:
"Object reference not set to an instance of an object."

I am using following code
void load()
{
Outlook.MAPIFolder Task = ns.
GetDefaultFolder(Outlook.OlDefaultFolders.olFolder Tasks);
}

UnregisterEvent()
{
// This line throw exception , Object reference not set to an instance of an
object
items.ItemAdd -= new
Outlook.ItemsEvents_ItemAddEventHandler(this.Items _ItemAdd);
}
. . . .
. . .. .
Following piece of code exist in another class
Item_AddEvent()
{
olTaskIem -- add some UserProperty
olTaskItem.Save() // this functin raise Item Add event
TaskFolderHandler objTask = TaskFolderHandler();
objTask . UnregisterEvent();
}
. . . ..


Can anyone figure out why error is being raised, and how I overcome this
problem?

Thanks i nadvance


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

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