'How to detect other outlook events such as "Forward as attachment", "Reply with Meeting"

Out of the box outlook provides the following:

((Outlook.ItemEvents_10_Event)this._mailItem).Reply += new Outlook.ItemEvents_10_ReplyEventHandler(MailItem_Reply);
((Outlook.ItemEvents_10_Event)this._mailItem).ReplyAll += new Outlook.ItemEvents_10_ReplyAllEventHandler(MailItem_ReplyAll);
((Outlook.ItemEvents_10_Event)this._mailItem).CustomAction += new Outlook.ItemEvents_10_CustomActionEventHandler(MailItem_CustomAction);
((Outlook.ItemEvents_10_Event)this._mailItem).Forward += new Outlook.ItemEvents_10_ForwardEventHandler(MailItem_Forward);

However, is there a way to detect other events such as:

  • Reply with Meeting
  • Forward as Attachment


Solution 1:[1]

There are no specific events for those actions but the standard Reply and Forward events will still fire. You can also tell that they clicked those buttons by inspecting the item type or attachment in the newly created item.

Solution 2:[2]

OOM exposes ForwardAsAttachment as an event with the dispid of 0x0000F618, it is just the type library does not expose it. "Reply with meeting" is 0x0000F5FD.

You can hook those events using IConnectionPointContainer / IConnectionPoint using raw COM - you can see the events firing in OutlookSpy (I am its author): select an item, click Item button on the OutlookSpy toolbar, go to the Events tab, click "Forward As Attachment", see the event logged in "Events Log" list at the bottom of the Item window.

If using Redemption (I am also its author) is an option, it exposes these events on the SafeMailItem object:

private SafeMailItem _sItem;
private MailItem _oItem;
...
_oItem = _application.ActiveExplorer().Selection[1];
_sItem = new SafeMailItem();
_sItem.Item = _oItem;
_sItem.ForwardAsAttachment += OnForwardAsAttachment;
...
private void OnForwardAsAttachment(object Forward, ref bool Cancel)
{
    MailItem newMessage = (MailItem)Forward;
    if (OlSensitivity.olConfidential == _oItem.Sensitivity)
    {
        MessageBox.Show($"Confidential message '{_oItem.Subject}' cannot be forwarded");
        Cancel = true;
    }
    else
    {
        newMessage.Subject = _oItem.Subject;
        newMessage.Body = $"Please see the attached message '{_oItem.Subject}'.";
    }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Eric Legault
Solution 2