![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
Hi NG.
I'm trying to write an application or add-in that has to act on some events from BCM for Outlook 2007. The events i'm interested in are events like Created, Updated and Deleted on entities/objects like Accounts, Contacts etc. (most of which are ContactItem objects). I have been able to find "some" events on the ContactItem object but far from enough to satisfy my needs. I would very much like to know: ------------------------------- 1) Where do I find these events (what objects should I be looking at if not ContactItem) ? 2) How do I go about writing and adding these eventhandlers (I've seen an example in VBA but not for the objects I'm interested in and everything I've tried with any existing event on the objects of my interest have not been successful) ? ------------------------------- I write in C# myself. If anyone can answer any of these questions and maybe even supply code examples or links to some "useful" examples it would be very much appreciated, thanks ![]() /Aidal |
#2
|
|||
|
|||
![]()
You might want to start the documentation at http://msdn2.microsoft.com/en-us/library/aa431857.aspx. For events, you'll be using those exposed by the Outlook object model, so you might also find http://msdn.microsoft.com/vcsharp/de...ol03csharp.asp and http://www.outlookcode.com/codedetail.aspx?id=797 useful.
-- 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 ... Hi NG. I'm trying to write an application or add-in that has to act on some events from BCM for Outlook 2007. The events i'm interested in are events like Created, Updated and Deleted on entities/objects like Accounts, Contacts etc. (most of which are ContactItem objects). I have been able to find "some" events on the ContactItem object but far from enough to satisfy my needs. I would very much like to know: ------------------------------- 1) Where do I find these events (what objects should I be looking at if not ContactItem) ? 2) How do I go about writing and adding these eventhandlers (I've seen an example in VBA but not for the objects I'm interested in and everything I've tried with any existing event on the objects of my interest have not been successful) ? ------------------------------- I write in C# myself. If anyone can answer any of these questions and maybe even supply code examples or links to some "useful" examples it would be very much appreciated, thanks ![]() /Aidal |
#3
|
|||
|
|||
![]()
Sue Mosher [MVP-Outlook] skrev:
You might want to start the documentation at http://msdn2.microsoft.com/en-us/library/aa431857.aspx. For events, you'll be using those exposed by the Outlook object model, so you might also find http://msdn.microsoft.com/vcsharp/de...ol03csharp.asp and http://www.outlookcode.com/codedetail.aspx?id=797 useful. Ok, I've checked out the links and I also build the test add-in from one of the links... So I did learn somthing and it was useful but still not what I wanted. I found from what I read and also tested a little that maybe Explorers and Inspectors could be useful, but from what I saw, it's about the UI areas and forms in Outlook not object events. I did consider maybe one could access the "right" form and then find the "right" button and then subscribe to it's Clicked event, using Explorers or Inspectors, but if an object like an Account (which is infact an Outlook.ContactItem) is accessible from other places than from the form used for Accounts, then this method doesn't work, because the object could be altered without ever openening the Account form hence making the subscribtion to the Save- or SaveAndClose-button on the form completely useless. ------------------- So, if anyone could provide an example or a link to one that explains how to: 1) Do somthing when ever a ContactItem (or Account) is created. 2) Do somthing when ever a ContactItem (or Account) is edited. 3) Do somthing when ever a ContactItem (or Account) is deleted. I do realize that Created and Edited might infact just be "Saved" and that would be ok as well. Wether this be subscribing to pre-defined events (which I have been unable to find), creating custom events or using whatever other means to get a notification when these events (1, 2 and 3) occurres, doesn't matter to me as long as it works and as long as it will always trigger regardless of from where and by whom the object was altered. /Aidal |
#4
|
|||
|
|||
![]()
1) Do somthing when ever a ContactItem (or Account) is created.
Subscribe to the MAPIFolder.Items.ItemAdd event for the desired folder(s). The sample at http://www.outlookcode.com/codedetail.aspx?id=456 is for the Sent Items folder, but it can supplement the information on that event in Help. 2) Do somthing when ever a ContactItem (or Account) is edited. MAPIFolder.Items.ItemChange event. Another sample to supplement what's in Help: http://www.outlookcode.com/codedetail.aspx?id=566 3) Do somthing when ever a ContactItem (or Account) is deleted. There's no surefire way to catch that until Outlook 2007. ContactItem.BeforeDelete fires only if the user has the item open and MAPIFolder.Items.ItemRemove doesn't return the item that was removed. One approach is to maintain your own list of what items are in each folder and check it against the actual folder contents whenever ItemRemove fires. -- 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: You might want to start the documentation at http://msdn2.microsoft.com/en-us/library/aa431857.aspx. For events, you'll be using those exposed by the Outlook object model, so you might also find http://msdn.microsoft.com/vcsharp/de...ol03csharp.asp and http://www.outlookcode.com/codedetail.aspx?id=797 useful. Ok, I've checked out the links and I also build the test add-in from one of the links... So I did learn somthing and it was useful but still not what I wanted. I found from what I read and also tested a little that maybe Explorers and Inspectors could be useful, but from what I saw, it's about the UI areas and forms in Outlook not object events. I did consider maybe one could access the "right" form and then find the "right" button and then subscribe to it's Clicked event, using Explorers or Inspectors, but if an object like an Account (which is infact an Outlook.ContactItem) is accessible from other places than from the form used for Accounts, then this method doesn't work, because the object could be altered without ever openening the Account form hence making the subscribtion to the Save- or SaveAndClose-button on the form completely useless. ------------------- So, if anyone could provide an example or a link to one that explains how to: 1) Do somthing when ever a ContactItem (or Account) is created. 2) Do somthing when ever a ContactItem (or Account) is edited. 3) Do somthing when ever a ContactItem (or Account) is deleted. I do realize that Created and Edited might infact just be "Saved" and that would be ok as well. Wether this be subscribing to pre-defined events (which I have been unable to find), creating custom events or using whatever other means to get a notification when these events (1, 2 and 3) occurres, doesn't matter to me as long as it works and as long as it will always trigger regardless of from where and by whom the object was altered. /Aidal |
#5
|
|||
|
|||
![]()
Sue Mosher [MVP-Outlook] skrev:
1) Do somthing when ever a ContactItem (or Account) is created. Subscribe to the MAPIFolder.Items.ItemAdd event for the desired folder(s). The sample at http://www.outlookcode.com/codedetail.aspx?id=456 is for the Sent Items folder, but it can supplement the information on that event in Help. 2) Do somthing when ever a ContactItem (or Account) is edited. MAPIFolder.Items.ItemChange event. Another sample to supplement what's in Help: http://www.outlookcode.com/codedetail.aspx?id=566 3) Do somthing when ever a ContactItem (or Account) is deleted. There's no surefire way to catch that until Outlook 2007. ContactItem.BeforeDelete fires only if the user has the item open and MAPIFolder.Items.ItemRemove doesn't return the item that was removed. One approach is to maintain your own list of what items are in each folder and check it against the actual folder contents whenever ItemRemove fires. Thanks for your reply Sue. I will try this out right away. By the way, about the "deleted" event, it is infact Outlook + BCM 2007 I'm developing for. /Aidal |
#6
|
|||
|
|||
![]()
Sorry, I missed that. For Outlook 2007, you can use the Folder.BeforeItemMove event.
-- 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 ... By the way, about the "deleted" event, it is infact Outlook + BCM 2007 I'm developing for. |
#7
|
|||
|
|||
![]()
Sue Mosher [MVP-Outlook] skrev:
1) Do somthing when ever a ContactItem (or Account) is created. Subscribe to the MAPIFolder.Items.ItemAdd event for the desired folder(s). The sample at http://www.outlookcode.com/codedetail.aspx?id=456 is for the Sent Items folder, but it can supplement the information on that event in Help. 2) Do somthing when ever a ContactItem (or Account) is edited. MAPIFolder.Items.ItemChange event. Another sample to supplement what's in Help: http://www.outlookcode.com/codedetail.aspx?id=566 3) Do somthing when ever a ContactItem (or Account) is deleted. There's no surefire way to catch that until Outlook 2007. ContactItem.BeforeDelete fires only if the user has the item open and MAPIFolder.Items.ItemRemove doesn't return the item that was removed. One approach is to maintain your own list of what items are in each folder and check it against the actual folder contents whenever ItemRemove fires. Ok, I've checked out your example. I'm not sure I've translated your code correctly to C# though. I've created my own little class to test and am trying to use it from a console application. ----------------------------------- // available within the class Outlook.ApplicationClass olAppClass; Outlook.NameSpace olNameSpace; Outlook.Folders olFolders; Outlook.MAPIFolder olBcmRootFolder; // Within my class constructor olAppClass = new Outlook.ApplicationClass(); olNameSpace = olAppClass.GetNamespace("MAPI"); olFolders = olNameSpace.Session.Folders; olBcmRootFolder = olFolders["Business Contact Manager"]; olBcmRootFolder.Folders["Accounts"].Items.ItemAdd += new Outlook.ItemsEvents_ItemAddEventHandler(InstanceAd ded_Account); // No longer within constructor public void InstanceAdded_Account(object item) { Console.WriteLine("account created: " + ((Outlook.ContactItem)item).FullName); } ----------------------------------- This should give me some console output when an Account is created or am I missing somthing here? Does the delegate have to have a certain name in order for it to work maybe? /Aidal |
#8
|
|||
|
|||
![]()
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.
-- 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: 1) Do somthing when ever a ContactItem (or Account) is created. Subscribe to the MAPIFolder.Items.ItemAdd event for the desired folder(s). The sample at http://www.outlookcode.com/codedetail.aspx?id=456 is for the Sent Items folder, but it can supplement the information on that event in Help. 2) Do somthing when ever a ContactItem (or Account) is edited. MAPIFolder.Items.ItemChange event. Another sample to supplement what's in Help: http://www.outlookcode.com/codedetail.aspx?id=566 3) Do somthing when ever a ContactItem (or Account) is deleted. There's no surefire way to catch that until Outlook 2007. ContactItem.BeforeDelete fires only if the user has the item open and MAPIFolder.Items.ItemRemove doesn't return the item that was removed. One approach is to maintain your own list of what items are in each folder and check it against the actual folder contents whenever ItemRemove fires. Ok, I've checked out your example. I'm not sure I've translated your code correctly to C# though. I've created my own little class to test and am trying to use it from a console application. ----------------------------------- // available within the class Outlook.ApplicationClass olAppClass; Outlook.NameSpace olNameSpace; Outlook.Folders olFolders; Outlook.MAPIFolder olBcmRootFolder; // Within my class constructor olAppClass = new Outlook.ApplicationClass(); olNameSpace = olAppClass.GetNamespace("MAPI"); olFolders = olNameSpace.Session.Folders; olBcmRootFolder = olFolders["Business Contact Manager"]; olBcmRootFolder.Folders["Accounts"].Items.ItemAdd += new Outlook.ItemsEvents_ItemAddEventHandler(InstanceAd ded_Account); // No longer within constructor public void InstanceAdded_Account(object item) { Console.WriteLine("account created: " + ((Outlook.ContactItem)item).FullName); } ----------------------------------- This should give me some console output when an Account is created or am I missing somthing here? Does the delegate have to have a certain name in order for it to work maybe? /Aidal |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
BCM 2007 Events and EventHandlers | Aidal | Outlook - General Queries | 1 | December 6th 06 01:15 PM |
Installed Office 2007 Pro, BCM is not there, how to get module? | blewis999 | Outlook - Using Contacts | 0 | November 23rd 06 03:29 AM |
BCM crashed - reinstalled - now I can't see BCM in Oulook | CGINUSA | Outlook - Installation | 0 | July 18th 06 10:06 AM |
Migrating BCM files from 2003 to 2007 | JimB | Outlook - Installation | 1 | July 16th 06 02:18 PM |
Outlook 2007 w/BCM: Cannot Reinstall | RDU | Outlook - Installation | 0 | July 2nd 06 04:05 PM |