• Subject: item_open event firing twice while searching a contact !
  • Author: parasbits2k@gmail.com
  • Date: 09 Apr
  • References:
Hi,

Iam opening my custom contact form for contact items on item_open
event. Iam facing an issue here. If I have the same contact with email
address in different contact folders (say Fold1 and Fold2) and if I
try to search for that contact from the search box (given in Outlook
Toolbar), the "chose contact" windows with both the entries pops up.
If I select an entry (from Fold1) and open it, the item_open event is
fired and there Iam supressing the default contact form (cancel =true
parameter) for opening my custom form. As soon as the custom form is
opened the item_open event is fired again second time and which is
causing trouble.

Note: I have checked the parent folder property for the contact item.
Parent folder name(Fold1) is for the selected contact when the event
is fired first time and parent folder name (Fold2) comes for the
second duplicate contact when the event is fired second time.

Is there any way to prevent the item_open event firing second time ?

Any help is appreciated.

Thanks,

Paras.



Sample Code:

***********************************************************

public partial class ThisAddIn
{
Outlook.ContactItem m_contactItem;
Outlook.Inspectors m_inspectors;

private void ThisAddIn_Startup(object sender, System.EventArgs
e)
{
m_inspectors = Application.Inspectors;
m_inspectors.NewInspector += new
Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(m_inspectors_NewInspector);

}

void
m_inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector
Inspector)
{
if (Inspector.CurrentItem is Outlook.ContactItem)
{
m_contactItem = Inspector.CurrentItem as
Outlook.ContactItem;
m_contactItem.Open += new
Microsoft.Office.Interop.Outlook.ItemEvents_10_OpenEventHandler(m_contactItem_Open);

}
}

void m_contactItem_Open(ref bool Cancel)
{
Cancel = true; //supress the default contact inspector.
Outlook.MAPIFolder parent =
(Outlook.MAPIFolder)m_contactItem.Parent;

//open custom form
.........

}

*****************************************************
09 Apritem_open event firing twice while searching a contact !.parasbits2k@gmail.com
10 Apr\ Re: item_open event firing twice while searching a contact !.parasbits2k@gmail.com
10 Apr   \ Re: item_open event firing twice while searching a contact !.Ken Slovak - [MVP - O...
12 Apr      \ Re: item_open event firing twice while searching a contact !.parasbits2k@gmail.com
14 Apr         \ Re: item_open event firing twice while searching a contact !.Ken Slovak - [MVP - O...
All times are in (US) Eastern Daylight Time (GMT -4:00)