0

I am trying to get the email account associated with some shared mailbox whose email is sent as a parameter. The followed code works fine when I execute it on Outlook 2013. However, it throws a System.InvalidCastException on Outlook 2016.

public string GetUserSMTPAddressOfSharedMailbox(string email)
{
    Redemption.IRDOStore store = RdoSession.GetSharedMailbox(email);
    if(store != null && store.StoreAccount != null)
    {
          return store.StoreAccount.CurrentUser.SMTPAddress;
    }

    return null;
}


System.InvalidCastException: Unable to cast 
    COM object of type 'System.__ComObject' to interface type 
    'Redemption.IRDOSession'. This operation failed because the 
    QueryInterface call on the COM component for the interface with IID 
    '{E54C5168-AA8C-405F-9C14-A4037302BD9D}' failed due to the following 
    error: No such interface 
    supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr 
    pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
at Redemption.IRDOSession.GetSharedMailbox(Object NameOrAddressOrObject)
Gabriel
  • 13
  • 4
  • Please send an email from the support page - http://www.dimastr.com/redemption/contact.htm. We will send you the debug version of Redemption. – Dmitry Streblechenko Jun 27 '17 at 00:39
  • @DmitryStreblechenko thanks for your answer. I don't think the problem is related to the method itself. I changed the approach trying to loop through the Stores. Before looping I execute this command *RdoSession.Stores.Count*. So, the same exception is thrown. My guessing is that it is related to some Thread thing. This [link](https://stackoverflow.com/questions/16938467/why-cannot-i-cast-my-com-object-to-the-interface-it-implements-in-c) talks about it, but I don't know how to fix it yet. – Gabriel Jun 27 '17 at 20:31
  • Let's see what the debug version of Redemption shows... – Dmitry Streblechenko Jun 28 '17 at 15:09

0 Answers0