none
C# create new Outlook contact RRS feed

  • Question

  • Hi,

    I create from a *.Exe a new Outlook contact. That works most of the time.

    If Outlook is not running it sometimes does not work. This means, that on one computer it only needs some seconds to create the contact. On other computers the contact is not created.

    dynamic oApp = null;
    dynamic oContactItem = null;
    dynamic oNameSpace = null;
    
    var objectType = Type.GetTypeFromProgID(Consts.OutlookProgId);
    oApp = Activator.CreateInstance(objectType);
    oNameSpace = oApp.GetNamespace("MAPI");
    
    const int olContactItem = 2;
    oContactItem = oApp.CreateItem(olContactItem) as _ContactItem;
    
    oContactItem.BusinessTelephoneNumber = "13456";
    oContactItem.Display(false);
    

     

    On the computer where it does not work, I found a catched Exception 0x8001010A (RPC_E_SERVERCALL_RETRYLATER).

    How can I solve this problem? Do I have to add a "retry in 1 second" loop in the case that the exception is catched?

    Thanks
    Christian

    Friday, June 17, 2016 3:00 PM

Answers

All replies