0
votes

In my Outlook Addin I subscribed to AttachmentRemove and AttachmentAdd of MailItem.

The Add Event fires while the Remove event is not fired in Outlook 2016. Outlook 2013 Both works. Both events are subscribed and unsubscribed the same time and the same way. I'm pretty sure no object is collected that would prevent raising the event.


edit (Version info)

Office Versions:

  • Microsoft Outlook 2016 MSO (16.0.13801.20240) 32-bit 2102 (Build 13801.20294 Click-to-Run)
  • Microsoft Outlook 2016 (16.0.5113.1000) MSO (13.0.5122.1000) 32-Bit

Both systems where office is installed are 64bit systems.


edit (code snipped)

public CommonItemInternal(object item)
{
    if (item == null)
        return;
    this.UniqueId = GetUniqueId(item);
    commonItemLookup.Add(this.UniqueId, this);
    this.Item = item;

    if (this.Item is MailItem)
    {
        var mailItem = this.Item as MailItem;
        mailItem.PropertyChange += this.COM_CommonItemInternal_PropertyChange;
        mailItem.AttachmentRemove += this.COM_mailItem_AttachmentRemove; // <-- Does not get called

        mailItem.AttachmentAdd += this.COM_mailItem_AttachmentAdd; // <-- Get called
    }
}
1
What is the actual code where you subscribe to events? How objects are declared in the code?Eugene Astafiev
It makes sense to specify the Outlook build number and its bitness.Eugene Astafiev
@EugeneAstafiev sorry for the delayed response. I added the versions.lokimidgard
@EugeneAstafiev I added also the codesnipped where I subscribe to the events.lokimidgard

1 Answers

0
votes

First of all, make sure the source object is declared at the global scope the garbage collector doesn't swipe it out from the heap. Second, try to save the item. The Outlook object model may not react on UI changes until you switch the cursor to another field or save the item. Third, it is not clear what code is used for handling the AttachmentRemove event. I'd suggest posting all the code or just the minimum reproducible sample code.