I am working on a VSTO Outlook2010 client addin. I have a ribbon and it shows up in new email explorer window. I need to write a method that does something when the new email window is closed. I know the window closes on its own when the email is sent, but I need a method that fires up when window is closed without the email being send, such as when the user wants to cancel out.
Any idea with sample code would be highly appreciated.
I tried this from another posts. below 2 lines says: cannot implicitly convert type . An explicit conversion exists. Are you missing a cast?
Inspector OpenedMailItem;
//within the start-up method
Inspector insp = this.Application.Inspectors;
insp.NewInspector += new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(OnNewInspector);
//new function, within class
public void OnNewInspector(Outlook.Inspector inspector)
{
if (inspector.CurrentItem is Microsoft.Office.Interop.Outlook.MailItem)
{
OpenedMailItem = inspector.CurrentItem as Microsoft.Office.Interop.Outlook.MailItem;
((ItemEvents_10_Event)OpenedMailItem).Close += new Outlook.ItemEvents_10_CloseEventHandler(MailItem_Close);
}
}
void(MailItem)
{
//something
}
Got so many errors and hovering over sasy: cannot implicitly convert type . An explicit conversion exists. Are you missing a cast?
I am importing all this:
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Outlook = Microsoft.Office.Interop.Outlook;
using Excel = Microsoft.Office.Interop.Excel;
using System.Windows.Forms; using System.Net;
using System.Web; using System.IO;
using System.Text.RegularExpressions;
using Redemption;
using System.Runtime.InteropServices;
using Microsoft.Office.Interop.Outlook;
using Exception = System.Exception;
Trap the Application.Inspectors.NewInspector event, add the new inspector to a list of inspectors. Listen for the Inspector.Close event. When it fires, remove the inspector from the list.