InlineResponse and ProcessAttachmentAdd

Add-in Express™ Support Service
That's what is more important than anything else

InlineResponse and ProcessAttachmentAdd
Getting event when attachment is added/removed to/from email 
Subscribe
Gutek Jakub




Posts: 27
Joined: 2017-06-06
Is there a way to access attachments that are added to mail in InlineResponse?

Connecting to mail item events like ProcessAttachmentAdd etc does not work. If InlineResponse mode is disabled it works as expected. But with InlineResponse mode events are not fired.

Moreover, trying to access GetInspector from mail is causing InlineResponse to behave unpredictably - basically next time you will move to email it will not load draft, ie. when you editing email and then moving to another one and coming back to this one.

Any help will be appreciated!
Posted 13 Dec, 2017 07:49:19 Top
Andrei Smolin


Add-in Express team


Posts: 14300
Joined: 2006-05-11
Hello Jakub (correct?),

Call Explorer.ActiveInlineResponse to get the item to connect to.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Dec, 2017 08:08:27 Top
Gutek Jakub




Posts: 27
Joined: 2017-06-06
ok, i was able to do this by:


private void OnOutlookExplroerInlineResponse(object sender, object itemObject)
{
    var explorer = this.OutlookApp.ActiveExplorer();
    var inlineRes = explorer.GetType()
        .InvokeMember("ActiveInlineResponse"
            , System.Reflection.BindingFlags.GetProperty
                | System.Reflection.BindingFlags.Instance
                | System.Reflection.BindingFlags.Public
            , null
            , explorer
            , null) as MailItem;

    if (inlineRes != null)
    {
        inlineRes.AttachmentAdd += (attachment) =>
        {
            //
        };

        inlineRes.AttachmentRemove += (attachment) =>
        {
            //
        };
    }
        

    //

}


but is there any other option to do it? now i have events wired to item that will probably leak.
Posted 13 Dec, 2017 08:12:50 Top
Andrei Smolin


Add-in Express team


Posts: 14300
Joined: 2006-05-11
Detach from the events in the InlineResponseClose event.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Dec, 2017 09:50:29 Top
Gutek Jakub




Posts: 27
Joined: 2017-06-06
thank you

this should do the trick.
Posted 13 Dec, 2017 10:20:56 Top
Andrei Smolin


Add-in Express team


Posts: 14300
Joined: 2006-05-11
Note that in the code you provided, the events will be disconnected as soon as the GC collects unused objects and var inlineRes among them. To avoid this, declare it on the class level.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Dec, 2017 10:25:43 Top
Gutek Jakub




Posts: 27
Joined: 2017-06-06
Yep, this is also the only way to detach them :)

thanks for you help on this
Posted 13 Dec, 2017 11:10:51 Top
Andrei Smolin


Add-in Express team


Posts: 14300
Joined: 2006-05-11
You are welcome :)

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 14 Dec, 2017 03:37:15 Top