View Single Post
  #3  
Old July 4th 06, 08:29 AM posted to microsoft.public.outlook.program_forms
DavidH&P
external usenet poster
 
Posts: 16
Default 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




Ads