Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook - Using Forms (http://www.outlookbanter.com/outlook-using-forms/)
-   -   ItemAdd event with Outlook2007 (http://www.outlookbanter.com/outlook-using-forms/19653-itemadd-event-outlook2007.html)

DavidH&P July 3rd 06 08:19 PM

ItemAdd event with Outlook2007
 
hi,
can anyone help me to find what's wrong in my code ?
I'm using VSTOv3 and Outlook2007 beta2,
I try to use the ItemAdd event but any messageBox appear when i move a mail
into the inbox folder or when a new mail arrives into this folder.
-----------------------------
Outlook.NameSpace mapiNamespace = this.GetNamespace("MAPI");
Outlook.MAPIFolder inBox = (Outlook.MAPIFolder)
this.ActiveExplorer().Session.GetDefaultFolder(Out look.OlDefaultFolders.olFolderInbox);

Outlook.MAPIFolder oFolderSurveille = inBox;
Outlook.Items oItems = oFolderSurveille.Items;
oItems.ItemAdd += new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemA ddEventHandler(oItems_ItemAdd);

private void oItems_ItemAdd(object Item)
{
MessageBox.Show("ItemAdd event");
}
--------------------------------------

thanks,

David


Fidget Brain July 3rd 06 11:08 PM

ItemAdd event with Outlook2007
 
try making the oItems field into a class scoped field rather than a local
scoped field. there is a known issue, where an event handler will not fire
for a local scoped field, because it is getting garbage collected.

"DavidH&P" wrote in message
...
hi,
can anyone help me to find what's wrong in my code ?
I'm using VSTOv3 and Outlook2007 beta2,
I try to use the ItemAdd event but any messageBox appear when i move a
mail
into the inbox folder or when a new mail arrives into this folder.
-----------------------------
Outlook.NameSpace mapiNamespace = this.GetNamespace("MAPI");
Outlook.MAPIFolder inBox = (Outlook.MAPIFolder)
this.ActiveExplorer().Session.GetDefaultFolder(Out look.OlDefaultFolders.olFolderInbox);

Outlook.MAPIFolder oFolderSurveille = inBox;
Outlook.Items oItems = oFolderSurveille.Items;
oItems.ItemAdd += new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemA ddEventHandler(oItems_ItemAdd);

private void oItems_ItemAdd(object Item)
{
MessageBox.Show("ItemAdd event");
}
--------------------------------------

thanks,

David




DavidH&P July 4th 06 08:29 AM

ItemAdd event with Outlook2007
 
Thanks,

it solves my problem !

"Fidget Brain" wrote:

try making the oItems field into a class scoped field rather than a local
scoped field. there is a known issue, where an event handler will not fire
for a local scoped field, because it is getting garbage collected.

"DavidH&P" wrote in message
...
hi,
can anyone help me to find what's wrong in my code ?
I'm using VSTOv3 and Outlook2007 beta2,
I try to use the ItemAdd event but any messageBox appear when i move a
mail
into the inbox folder or when a new mail arrives into this folder.
-----------------------------
Outlook.NameSpace mapiNamespace = this.GetNamespace("MAPI");
Outlook.MAPIFolder inBox = (Outlook.MAPIFolder)
this.ActiveExplorer().Session.GetDefaultFolder(Out look.OlDefaultFolders.olFolderInbox);

Outlook.MAPIFolder oFolderSurveille = inBox;
Outlook.Items oItems = oFolderSurveille.Items;
oItems.ItemAdd += new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemA ddEventHandler(oItems_ItemAdd);

private void oItems_ItemAdd(object Item)
{
MessageBox.Show("ItemAdd event");
}
--------------------------------------

thanks,

David






All times are GMT +1. The time now is 05:08 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