I\'m working on an application that should capture the Outlook 2013 Send event. I have used a C# project to do the required task.
In particular I have used following
The following steps works fine at my side.
Import the namespace:
using Outlook = Microsoft.Office.Interop.Outlook; using System.Windows.Forms;
5.Replace the original system generated fields:
private object applicationObject;
private object addInInstance;
with the following new fields: (No ItemSend event)
public Outlook.Application OutlookApplication;
public Outlook.Inspectors OutlookInspectors;
public Outlook.Inspector OutlookInspector;
public Outlook.MailItem OutlookMailItem;
6.In the OnConnection method, replace all the system generated codes with the following ones:
OutlookApplication = application as Outlook.Application;
OutlookInspectors = OutlookApplication.Inspectors;
OutlookInspectors.NewInspector += new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(OutlookInspectors_NewInspector);
OutlookApplication.ItemSend +=new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler(OutlookApplication_ItemSend);
7.Add the event handler function OutlookInspectors_NewInspector:
void OutlookInspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
{
OutlookInspector = (Outlook.Inspector)Inspector;
if (Inspector.CurrentItem is Outlook.MailItem)
{
OutlookMailItem = (Outlook.MailItem)Inspector.CurrentItem;
}
}
8.Add the event handler function OutlookApplication_ItemSend:
void OutlookApplication_ItemSend(object Item, ref bool Cancel)
{
string strchkTo = OutlookMailItem.To;
string strchk = "hello Welcome to c#";
MessageBox.Show(strchk + "\r\n" + strchkTo);
}