How to Unregister events

V

Virda

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.olFolderTasks);
}

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top