none
Outlook 2010 add-in: MailItem.Move() raises the exception 0x80040125 RRS feed

  • Question

  • Since the migration to Microsoft Exchange Server 2013 my outlook 2010 add-In throws sporadically the exception 0x80040125 by invoking of mailitem.move().

    I found out, that the exception occurs only when a re-connect to MS Exchange has been preceded (MAPI_E_RECONNECTED).

    The whole problem is, that I have than to restart the add-in (I have to restart my outlook completely*) to get it works again. 

    * But ironically, outlook seems to work also without a restart.

    P.S. I already read the following informations here (please search for it, I can not insert a Hyperlink): "What is MAPI_E_RECONNECTED?" (author: Stephen Griffin)

    Regratably the autor wrote not what he means with "and the call should be retried".

    regards

    cx-2

    Tuesday, February 9, 2016 7:52 AM

Answers

  • Hello Edward Z,

    I solved the issue by using the Exchange Web Services Managed API (EWS).
    As proposed by somebody, I've catched the exception and then I've called the similar EWS method EmailMessage.Move().

    But the overhead is now for me bigger, because I get more und more a premonition that managed MAPI and Co. are not good for managed .Net languages in a MS Outlook and a MS Exchange Environment and I have to migrate my whole MAPI code.

    Best regards

    cx-2



    • Marked as answer by cx-2 Thursday, February 18, 2016 6:02 AM
    • Edited by cx-2 Thursday, February 18, 2016 10:04 AM
    Thursday, February 18, 2016 6:01 AM

All replies

  • Hello,

    You can catch the exception, check out the HResult value and re-do the operation anew. Does it help?

    Tuesday, February 9, 2016 8:25 AM
  • Hello Eugene,

    do you mean something like this: (please feel free to correct me)

    try { mailItem.Move(mailFolder) } catch ( Exception ex ) { var w32ex = ex as Win32Exception; if ( w32ex == null ) { w32ex = ex.InnerException as Win32Exception; if (((uint)w32ex.ErrorCode & 0x0000FFFF) == Constants.MAPI_E_RECONNECTED) { mailItem.Move(mailFolder); }

    else

        {

          throw;

        } } else { int code = w32ex.ErrorCode; if (((uint)code & 0x0000FFFF) == Constants.MAPI_E_RECONNECTED) { mailItem.Move(mailFolder); }

    else

    {

    throw;

    } } }


    regards

    cx-2


    • Edited by cx-2 Tuesday, February 9, 2016 12:55 PM the code has been little bit improved
    Tuesday, February 9, 2016 12:43 PM
  • Hi cx-2,

    Did you code work? Since I have no environment to test, I suggest you mark a test.

    Based on the link below, it seems this error is caused by Outlook’s MAPI only. They will not appear with MAPICDO. Do you mind to try MAPICDO?

    # What is MAPI_E_RECONNECTED?

    https://blogs.msdn.microsoft.com/stephen_griffin/2012/02/27/what-is-mapi_e_reconnected/

    With the link below, it seems you need to set some properties like PR_PROFILE_ABP_ALLOW_RECONNECT to some positive value to turn on the reconnect logic and PR_PROFILE_SERVER_VERSION to 3000.

    # Getting Exchange MAPI's GC-Reconnect stuff to work

    http://blogs.msdn.com/b/jasonjoh/archive/2004/12/21/329175.aspx

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, February 10, 2016 2:44 AM
  • Hi Edward,

    no, my code is faulty.
    I let the PC run overnight and could so catch the error again. (because I can't reproduce the error by myself)

    Now I have seen, that I have explicit to treat a COMException error.
    So, now the next try:

    try
    {
        mailItem.Move(mailFolder);
    }
    catch (COMException ce)
    {
        if (ce.ErrorCode == unchecked((int)Constants.MAPI_E_RECONNECTED))
        {
          mailItem.Move(mailFolder);
        }
        else
        {
          throw;
        }
    }

    "Do you mind to try MAPI CDO?"
    No, when I can't solve this issue by catching the error and retried again to move the mail item, than I try MAPI CDO.


    "With the link below, it seems you need to set some properties like PR_PROFILE_ABP_ALLOW_RECONNECT to some positive value to turn on the reconnect logic and PR_PROFILE_SERVER_VERSION to 3000."

    I read it already, but I don't know where I can set (over c#) my mapi profile. I am using online connection to a corporate exchange server (2013). All data come from Active Directory and the user (that's me) doesn't have to configure (manually) anything.

    Thank you.

    Best regards

    cx-2

    Wednesday, February 10, 2016 7:38 AM
  • Hi,

    my solution to retry the invocation of mailItem.Move in a cacht-block has not worked. The same COMexception occurs again and again.

    The only one - and disappointed for me - solution, that I'm knowing at this time, is to restart my Outlook (not only to restart my add-in).

    I found also this article - maybe it interest someone: (please bing or google it: "FYI: Why are MAPI and CDO 1.21 not supported in managed (.NET) code?")

    See also: Collaboration Data Objects (CDO) 1.2.1 is not supported with Outlook 2010 and later Versions (KB2028411).

    Best regards.

    cx-2


    • Edited by cx-2 Wednesday, February 10, 2016 10:33 AM
    Wednesday, February 10, 2016 9:06 AM
  • Hi cx-2,

    I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.

    Sorry for any inconvenience and have a nice day!

    Best regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, February 11, 2016 6:24 AM
  • Hello Edward Z,

    I solved the issue by using the Exchange Web Services Managed API (EWS).
    As proposed by somebody, I've catched the exception and then I've called the similar EWS method EmailMessage.Move().

    But the overhead is now for me bigger, because I get more und more a premonition that managed MAPI and Co. are not good for managed .Net languages in a MS Outlook and a MS Exchange Environment and I have to migrate my whole MAPI code.

    Best regards

    cx-2



    • Marked as answer by cx-2 Thursday, February 18, 2016 6:02 AM
    • Edited by cx-2 Thursday, February 18, 2016 10:04 AM
    Thursday, February 18, 2016 6:01 AM