Getting Problem in Outlook Contact Item Event Handling
Hi,
I am developing Shared Add-in for outlook 2007.
I am handling Add/Edit Event for Outlook contact Item , but getting some problem.
When I am add any contact to Outlook it fires "Add Event" but then after calls "Edit Event" twice.
same as When Edit any Contact it fires "Edit Event" twice.
So I am not getting what this happening . I am going on the wrong direction or this is the fundamental mechanism of outlook events.
Here the code what I have done..
I am trying to solve this problem since last few days ..
So Please help me for same
Regards
Ctal
My Block of Code:
namespace MyAddin1
{
using System;
using Extensibility;
using System.Runtime.InteropServices;
using Outlook = Microsoft.Office.Interop.Outlook;
[GuidAttribute("5753D6D1-8F10-4536-8BD7-AA83EC82B78C"), ProgId("TestNexusOutlookAddin.Connect")]
public class Connect : Object, Extensibility.IDTExtensibility2
{
public static Outlook.Application myApplicationObject;
private Ol.Items ContactItem;
private Ol.Folder Contactfld = null;
private Ol.MAPIFolder _ContactFolder;
public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
{
try
{
// Get the initial Application object
myApplicationObject = (Ol.Application)application;
Ol.NameSpace _nameSpace = myApplicationObject.GetNamespace("MAPI");
#region Contact Item Events
_ContactFolder = _nameSpace.GetDefaultFolder(Ol.OlDefaultFolders.olFolderContacts);
ContactItem = (Ol.Items)_ContactFolder.Items;
ContactItem.ItemAdd += new Ol.ItemsEvents_ItemAddEventHandler(Items_ItemAdd);
ContactItem.ItemChange += new Ol.ItemsEvents_ItemChangeEventHandler(Items_ItemChange);
Contactfld = (Ol.Folder)_ContactFolder;
Contactfld.BeforeItemMove += new Ol.MAPIFolderEvents_12_BeforeItemMoveEventHandler(Items_BeforeItemMove);
//ContactItemClass.AttachmentAdd += new Ol.ItemEvents_10_AttachmentAddEventHandler(ContactItemClass_AttachmentAdd);
#endregion
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
addInInstance = addInInst;
if (connectMode != Extensibility.ext_ConnectMode.ext_cm_Startup)
{
OnStartupComplete(ref custom);
}
}
void Items_ItemAdd(object Item)
{
}
void Items_ItemChange(object Item)
{
Outlook._ContactItem NewContact;
NewContact = (Outlook._ContactItem)Item;
}
void Items_BeforeItemMove(object Item, Outlook.MAPIFolder MoveTo, ref bool Cancel)
{
}
}
}