Handling New Email event or open/reply/forward mail event

Hello All,

I am creating an Outlook Add-in using VSTO and would like to know what is the best way of handling "New Mail" or "Forward" or "Reply" events.

The code must also execute when using the "Send To --> Mail Recipient" from the windows explorer.

I have posted the code below but this does not seem to work when I try sending an email using "Send To --> Mail Recipient" or from any other application.

Thanks.

privatevoid ThisApplication_Startup(object sender,EventArgs e)

{

Outlook.NameSpace ns =this.Session;

Outlook.MAPIFolder inbox = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);

inspectors =this.Inspectors;

inspectors.NewInspector +=new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);

}

void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)

{

try

{

Object item = Inspector.CurrentItem;

if (itemis Outlook.MailItem)

{

mi = itemas Outlook.MailItem;

mi.Read +=new Microsoft.Office.Interop.Outlook.ItemEvents_10_ReadEventHandler(mi_Read);

mi.Open +=new Microsoft.Office.Interop.Outlook.ItemEvents_10_OpenEventHandler(mi_Open);

}

}

catch (Exception ex)

{

}

}

// This event occurs when a new mail is created

void mi_Open(refbool Cancel)

{

if (mi.Sent ==false)

{

}

}

[3100 byte] By [Hasib] at [2007-12-23]
# 1

Hasib,

Good question. Looks like this is Outlook behavior. You will be able to get a more effective response by posting your query to the Outlook discussion group mentioned below.

http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.office.developer.outlook.vba&lang=en&cr=US

Thanks.

NaveenYajaman-MSFT at 2007-8-30 > top of Msdn Tech,Visual Studio Tools for Office,Visual Studio Tools for Office...