none
CommandBarsClass.ExecuteMso(String idMso) method throwing Exception in Outlook 2016 RRS feed

  • Question

  • Hello experts,

    In our project (a Outlook addin), we were using call to the method: CommandBarsClass.ExecuteMso(String idMso) and that was running smooth. Recently, when we upgraded to Outlook 2016 [Monthly Channel Version 1710 (Build 8625.2121)], it started failing with the following exception message:

    Message :Error HRESULT E_FAIL has been returned from a call to a COM component.
    Source :office
    Stack Trace :   at Microsoft.Office.Core.CommandBarsClass.ExecuteMso(String idMso)

    Message :Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
    Source :
    Stack Trace :   at Microsoft.Office.Core.CommandBarsClass.ExecuteMso(String idMso)

    Later, came to know that, Microsoft has deprecated the call to Microsoft.Office.Core.CommandBarsClass.ExecuteMso(String idMso) method, which is now generating exception on uses. Support for the CommandBars also expired and as a result, our application is malfunctioning whenever the call is happen.

    Can anyone tell me, if that's correct, what would be the alternative to programmatically call the Reply/ReplyAll/Forward functionalities from code? Any help/article link will be highly appreciable.


    Kunal Chowdhury [Microsoft MVP - Windows Development]
    Windows 10 Champion, Active Blogger @ http://www.kunal-chowdhury.com
    Git Tutorial - http://git.kunal-chowdhury.com

    Wednesday, December 6, 2017 8:56 AM

All replies

  • Why do you need to simulate a click on a button for this?

    Retrieve the currently selected item from Application.ActiveExplorer.Selection, call MailItem.Reply / ReplyAll / Forward (returns new MailItem), call MailItem.Display.

    Note that you can try to use the Accessibility API to access the ribbon. If using Redemption is an option, it exposes SafeRibbon class that uses Accessibility API and allows to simulate mouse clicks - see http://www.dimastr.com/redemption/SafeRibbon.htm


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, December 6, 2017 7:55 PM
  • Hello Kunal,

    As Dmitry suggested, you could call Reply/ReplyAll/Forward method of item object instead of using CommandBarsClass.ExecuteMso.

    Besides, I could reproduce your issue using Reply/ReplyAll/Forward commands in a higher version Version 1711(Build 8730.2122). However, no all commands would fail. I test SendReceiveAll and UpdateFolder and they are fine.

    Since no document notes that commandbars object has been removed, I suggest you submit a feedback about the issue.

    Regards,

    Celeste

     


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, December 12, 2017 8:17 AM
    Moderator