Sorry, I don't write C# code, so I can't tell you why it's not working. From my limited ability to read C#, no problem jumps out at me.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
"Aidal" wrote in message ...
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