Home > Back-end >  When does Outlook's Explorer.ActiveInlineResponse property return null?
When does Outlook's Explorer.ActiveInlineResponse property return null?

Time:02-24

I'm attempting to determine when Outlook's Explorer.ActiveInlineResponse property will return null. The documentation link states, "This property returns Null (Nothing in Visual Basic) if no inline response is visible in the Reading Pane".

So far I've only been able to get ActiveInlineResponse to return null when sending mail from outside of Outlook. For example, a Word/Excel mail merge or from a VBA project that uses Outlook to send mail. Are there any other instances where ActiveInlineResponse will return null? I'm only concerned with Outlook mailitems.

Here's my question in code-

        Outlook.Explorer explorer = Globals.ThisAddIn.Application.ActiveExplorer();
        explorer = Globals.ThisAddIn.Application.ActiveExplorer();
        Outlook.MailItem mailItem = Item as Outlook.MailItem;

        if (explorer.ActiveInlineResponse is Outlook.MailItem)
        {
            if (explorer.ActiveInlineResponse == null)
            {
                //When would the ActiveInlineResponse be null?
            }

            else if (explorer.ActiveInlineResponse != null)
            {
                //ActiveInlineResponse is not null when an item is being composed inline (reply,reply all or forward)
            }
        }

Thanks!

CodePudding user response:

Of course - this is to be expected: Word/Excel etc. do not use inline response to send messages, they show messages in a separate inspector, which can be retrieved using Application.ActiveInspector.

Inline response (Application.ActiveExplorer.ActiveInlineResponse) is only shown when a user replies to or forwards a message.

CodePudding user response:

First of all, there is no call the ActiveExplorer method twice in the code:

Outlook.Explorer explorer = Globals.ThisAddIn.Application.ActiveExplorer();
explorer = Globals.ThisAddIn.Application.ActiveExplorer();

To get the currently selected item in Outlook's explorer windows you can use the Selection property of the Explorer class which returns a Selection object that contains the item or items that are selected in the explorer window. For example:

private void DisplaySelectedItems()
{
    Outlook.Selection selection =
        Application.ActiveExplorer().Selection;
    for (int i = 1; i <= selection.Count; i  )
    {
        OutlookItem myItem = new OutlookItem(selection[i]);
        myItem.Display();
    }
}

The Explorer.ActiveInlineResponse property returns an item object representing the active inline response item in the explorer reading pane (as it states, it is available for for any responses like replies and forwards).

You may find the following articles helpful:

  • Related