none
Bug in Outlook 2010 Add-In? RRS feed

  • Question

  • Hallo, i've got a strange issue.
    Please try the following steps to reproduce this:

    1. VS2010 (C#) - new Project -> Outlook 2010 Add-in (framework 3.5 or 4.0)
    2. add new item -> Ribbon (Visual Designer)
    3. change RibbonType to "Microsoft.Outlook.Mail.Compose"
    4. build and run the project
    5. open Excel 2010 -> Save and Send -> as attachment -> enter mail address and send
    6. right click on any cell in Excel -> format cell
    The format cell dialog will be opened in the background of excel and is not accessible (Excel seems to freeze)

    Can anyone confim this? Is this a bug?

    Thanks,
    Andreas


    Tuesday, July 3, 2012 9:13 PM

Answers

  • Hallo,

    i've got an answer from a Microsoft Developer Support Engineer, which seems to solve this issue. The solution is to release the inspector explicitly:

    public bool group_getVisible(Office.IRibbonControl control)
    {
        Outlook.Inspector insp = Globals.ThisAddIn.Application.ActiveInspector();
        System.Runtime.InteropServices.Marshal.ReleaseComObject(insp);
        insp = null;
        return true;
    }

    So, i need to do some more tests, but first it looks good.

    Regards,
    Andreas

    • Proposed as answer by David Barrett Thursday, July 19, 2012 9:00 AM
    • Marked as answer by andreas_0815 Thursday, July 19, 2012 10:52 AM
    Thursday, July 12, 2012 3:55 PM

All replies

  • Hi andress_0815,

    Thanks for posting in the MSDN Forum.

    I can reproduce your issue on my side. I will contact Microsoft engineers via internal channel to confirm it. I will let you know result as faster as I can.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, July 5, 2012 4:52 AM
    Moderator
  • Hi Tom,

    do you have any updates regarding this issue/bug?

    Andreas

    Monday, July 9, 2012 10:44 AM
  • Hi Andreas,

    After doing some digging, I see that we've had another customer report this problem but there is no known direct fix for this at this point. This problem will also happen with Word, and probably any other application that uses Simple MAPI to create a new modal window to send an e-mail message. If you want to pursue getting a hotfix, you can open a support incident and we can investigate this further.

    The workaround is to avoid using the Ribbon Designer and implement the custom ribbon via RibbonXML. There is a blog post on this topic here:

    http://blogs.msdn.com/b/dhruvkh/archive/2012/05/14/outlook-ribbon-woes-on-performing-send-as-e-mail-via-other-office-2010-apps.aspx


    Bill Jacob - Microsoft Customer Service & Support - Developer Messaging

    Monday, July 9, 2012 2:46 PM
  • Hi Bill,

    I've changed my code to RibbonXML now. But unfortunately, this didn't solved the problem. As soon I access the ActiveInspector the problem occurs again (I need this, because every time a new mail is created, I need to access the mail subject to add some text automatically).
    Code example:

    public bool group_getVisible(Office.IRibbonControl control) { Outlook.Inspector insp = Globals.ThisAddIn.Application.ActiveInspector(); ...
    return true; }

    Regards,
    Andreas

    Monday, July 9, 2012 9:51 PM
  • try to access inspector using following code:

    public bool group_getVisible(Office.IRibbonControl control)
     {
          Outlook.Inspector insp = (Outlook.Inspector)control.Context;
                return true;
     }

    Tuesday, July 10, 2012 7:24 AM
  • Hi DaminD,

    no - same result.

    Andreas

    Tuesday, July 10, 2012 9:34 AM
  • See if it helps if you don't use ActiveInspector() but instead check the Inspectors collection for an unhandled Inspector. If only 1 Inspector is opened you could try Inspectors[1].
     
    If that doesn't work you might need to try a hack to get Excel back on top. You could get the hWnd of the Excel window by using a pInvoke of FindWindow(). You'd use the Excel window caption for the window caption argument to FindWindow() with a class of "XLMAIN". Then you could use that hWnd with SetWindowPos(), sort of like this:
     
          retVal = SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
          retVal = SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
     
    That would first bring the window to the top of the z-order for everything and then leave it on top but not as a modal window.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "andreas_0815" <=?utf-8?B?YW5kcmVhc18wODE1?=> wrote in message news:9b2af81e-004e-4ef7-884f-6dccdd1874fd...

    Hi DaminD,

    no - same result.

    Andreas


    Ken Slovak MVP - Outlook
    Tuesday, July 10, 2012 2:17 PM
  • Hi Ken,

    I write this Add-In not for myself, but for a customer who wants to roll out this Add-In to over 1800 users - so the "hack" is no option!

    Regards,
    Andreas

    Tuesday, July 10, 2012 3:21 PM
  • Suit yourself. But handling Simple MAPI windows isn't officially supported for Outlook by MS, so a hack may be all that's available.
     
    I've used such hacks in many of my commercial addins, used by far more than a couple of thousand users...

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "andreas_0815" <=?utf-8?B?YW5kcmVhc18wODE1?=> wrote in message news:e057f363-e90e-4452-bb63-5171d471c496...

    Hi Ken,

    I write this Add-In not for myself, but for a customer who wants to roll out this Add-In to over 1800 users - so the "hack" is no option!

    Regards,
    Andreas


    Ken Slovak MVP - Outlook
    Tuesday, July 10, 2012 3:31 PM
  • Hi Andreas,

    As Ken said, there unfortunately is no fully-supported way to get various things working when the modal Simple MAPI-geneated messages are coming into play. The modality can cause Outlook and its  object model to basically stop and cause various bad behaviors. It's important to note that for about the past 20 years, the Simple MAPI API has specified that the new message window must be modal, so Outlook's handling of the message in this way is definitely by design.

    While it will not help you right now, there is good news coming in that Simple MAPI was updated with Windows 8 so in the future applications can use Simple MAPI and create a non-modal window. This will avoid these types of object model issues going forward.


    Bill Jacob - Microsoft Customer Service & Support - Developer Messaging

    Tuesday, July 10, 2012 8:37 PM
  • Hallo,

    after playing around a while, i've find out this issue does not occurs all the time. If you enter a mail address from the address book with the To...-Button this issue does not come up. But as soon you enter a mail address by typing and the suggestion list pops up, we have this issue. So it seems to depend on the suggestion list. Maybe i can do something with the current inspector... - I don't know.

    Any ideas?

    Andreas

    Wednesday, July 11, 2012 4:55 PM
  • If you use the Win32 API calls I mentioned that would solve the problem completely. If you don't want to do that I have no ideas that would work for you in all or most cases. See if Bill comes up with anything, but as MS doesn't support handling Simple MAPI windows in Outlook you might be out of luck.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "andreas_0815" <=?utf-8?B?YW5kcmVhc18wODE1?=> wrote in message news:35184c3c-0f0d-449a-bc03-459ee2787b6f...

    Hallo,

    after playing around a while, i've find out this issue does not occurs all the time. If you enter a mail address from the address book with the To...-Button this issue does not come up. But as soon you enter a mail address by typing and the suggestion list pops up, we have this issue. So it seems to depend on the suggestion list. Maybe i can do something with the current inspector... - I don't know.

    Any ideas?

    Andreas


    Ken Slovak MVP - Outlook
    Wednesday, July 11, 2012 4:58 PM
  • Hallo,

    i've got an answer from a Microsoft Developer Support Engineer, which seems to solve this issue. The solution is to release the inspector explicitly:

    public bool group_getVisible(Office.IRibbonControl control)
    {
        Outlook.Inspector insp = Globals.ThisAddIn.Application.ActiveInspector();
        System.Runtime.InteropServices.Marshal.ReleaseComObject(insp);
        insp = null;
        return true;
    }

    So, i need to do some more tests, but first it looks good.

    Regards,
    Andreas

    • Proposed as answer by David Barrett Thursday, July 19, 2012 9:00 AM
    • Marked as answer by andreas_0815 Thursday, July 19, 2012 10:52 AM
    Thursday, July 12, 2012 3:55 PM