I have an Outlook 2010 Add-In project written in C# using Visual Studio 2010.
Since the Add-In is overall working in Outlook 2013 I just want to make a slight modification, to prevent problems with the new InlineResponse feature in Outlook 2013.
I want to register an eventhandler for the InlineResponse event without upgrading to VS 2012 (because of the removed installer project). I read about using reflections to get the new events.
I don't get any exceptions, but the event doesn't trigger my handler (OnInlineResponse not called).
public partial class ThisAddIn
{
Outlook.Explorer _explorer;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
_explorer = Application.ActiveExplorer();
AddInlineResponseHandler();
}
private void AddInlineResponseHandler()
{
var einfo = _explorer.GetType().GetEvent("InlineResponse", BindingFlags.Public | BindingFlags.Instance);
if (einfo != null)
{
var handler = Delegate.CreateDelegate(einfo.EventHandlerType, this, this.GetType().GetMethod("OnInlineResponse", BindingFlags.NonPublic | BindingFlags.Instance), false);
einfo.AddEventHandler(_explorer, handler);
}
}
private void OnInlineResponse()
{
System.Windows.Forms.MessageBox.Show("InlineResponse");
}
}
Any suggestions how I might achieve the desired behaviour?