none
Outlook 2003 VSTO AddIn - Inspector window does not close RRS feed

  • Question

  • Hi,

    i have developed an Outlook 2003 AddIn with VSTO and VS 2008. The AddIn creates a new command bar with two buttons in an inspector window if an user opens a mail item. It also should work when a user clicks "Send To"-->"EMail Recipient" in the context menu of the explorer. Therefore i have created a timer in the UI-Thread of the addIn which ckecks every 2 seconds if there is an inspector window without the command bar. If such an inspector is found the command bar will be created on it.

    That works fine but there are some sideeffects.

    If an user opens an inspector by clicking Send To --> EMail Recipient and clicks "Send" the mail is sent but the inspector window remains open. The user has to close it manually.

    I know that "Send To" creates a MAPI call and that is not supported by MS. But is there any way to handle this?

    Any ideas?

    Thanks,

    Nick

    Thursday, July 5, 2012 8:10 AM

Answers

  • No, that's a typical problem with Simple MAPI handling called "ghost Inspectors".
     
    You can close them by clicking the X close box from the UI, but there isn't any access from the object model typically.
     
    What I do is to get the hWnd of the Inspector window when I start handling it, using FindWindow() with the Inspector caption and the class "rctrl_renwnd32".
     
    When I get the Inspector.Close() event I check a flag in the Inspector wrapper class to see if that item was a Simple MAPI item. If so I use code like this snippet to force the window to close (after I've released all my relevant objects):
     

    if (_simpleMAPI)

    {

        try

        {

            int retVal = PostMessage(_hWnd, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);

    WM_CLOSE = 0x10, and PostMessage() and FindWindow() are both used as pinvokes from the Win32 API's.


    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "DamianD" <=?utf-8?B?RGFtaWFuRA==?=> wrote in message news:6ef368df-7869-47db-8e6e-825a0e90824f...
    if window stays open then most probably you have somewhere unreleased reference to COM object that is used on that window.

    Ken Slovak MVP - Outlook
    Thursday, July 5, 2012 2:46 PM
    Moderator

All replies

  • if window stays open then most probably you have somewhere unreleased reference to COM object that is used on that window.
    Thursday, July 5, 2012 8:58 AM
  • No, that's a typical problem with Simple MAPI handling called "ghost Inspectors".
     
    You can close them by clicking the X close box from the UI, but there isn't any access from the object model typically.
     
    What I do is to get the hWnd of the Inspector window when I start handling it, using FindWindow() with the Inspector caption and the class "rctrl_renwnd32".
     
    When I get the Inspector.Close() event I check a flag in the Inspector wrapper class to see if that item was a Simple MAPI item. If so I use code like this snippet to force the window to close (after I've released all my relevant objects):
     

    if (_simpleMAPI)

    {

        try

        {

            int retVal = PostMessage(_hWnd, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);

    WM_CLOSE = 0x10, and PostMessage() and FindWindow() are both used as pinvokes from the Win32 API's.


    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "DamianD" <=?utf-8?B?RGFtaWFuRA==?=> wrote in message news:6ef368df-7869-47db-8e6e-825a0e90824f...
    if window stays open then most probably you have somewhere unreleased reference to COM object that is used on that window.

    Ken Slovak MVP - Outlook
    Thursday, July 5, 2012 2:46 PM
    Moderator