Thread: BCM 2007 events
View Single Post
  #9  
Old December 13th 06, 08:09 AM posted to microsoft.public.outlook.program_addins
Aidal
external usenet poster
 
Posts: 9
Default BCM 2007 events

Sue Mosher [MVP-Outlook] skrev:
That's on the right track but needs some refinement. You must to declare an explicit Items object at the class level, instantiate it in your procedure, and then create the event handler. The Items object must be a class-level object in order to persist so that it can fire events.


Ok, now I have this. I've created an Outlook.Items object like you
described, and attatched the event handler to that object - but it still
doesn't have any effect.
I still get no message in my console when an Account is created :/

To me the syntax here makes sense so either I'm very close or I'm just
misunderstanding your descriptions.
-----------------------------------------------
// class variables
private Outlook.ApplicationClass appClass;
private Outlook.Application app;
private Outlook.NameSpace nameSpace;
private Outlook.Folders folders;
private Outlook.MAPIFolder bcmRootFolder;
private Outlook.Items olItems;

// in constructor
this.appClass = new Outlook.ApplicationClass();
this.app = (Outlook.Application)this.appClass;
this.nameSpace = this.appClass.GetNamespace("MAPI");
this.folders = this.nameSpace.Session.Folders;
this.bcmRootFolder = this.folders["Business Contact Manager"];

this.olItems = this.bcmRootFolder.Folders["Accounts"].Items;
this.olItems.ItemAdd += new
Outlook.ItemsEvents_ItemAddEventHandler(InstanceAd ded_Account);

// outside constructor
public void InstanceAdded_Account(object item)
{
Console.WriteLine("ACCOUNT CREATED: " +
((Outlook.ContactItem)item).FullName);
}
-----------------------------------------------

/Aidal
Ads