Interface Member Invocations

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Getting a Contact in C#

After a Communicator object (implementing the IMessenger and other interfaces) is created, you can call methods and properties of the interfaces implemented by the object. The following C# code shows an attempt to retrieve a specified contact listed in the connected Communicator.

CommunicatorAPI.Messenger communicator = new CommunicatorAPI.Messenger();

public IMessengerContact GetContact(string signinName)
{
    return communicator.GetContact(signinName, communicator.MyServiceId) as IMessengerContact;
}

Getting a Contact in C/C++

Retrieving a contact in C/C++ is more involved than in C#. The following C/C++ code shows an attempt to retrieve a specified contact that is listed in the connected Communicator.

IMessenger m_pIMessenger = ...;

IMessengerContact* GetContact(BSTR bstrSigninName)
{
      // Get the ID of the service behind the connected Communicator.
      // Property invocation.
      BSTR bstrServiceId;
      hr = m_pIMessenger->get_MyServiceId(&bstrServiceId);
      if (FAILED(hr))
         return NULL;

      // Get the named contact: method invocation
      IMessengerContact* pIMessengerContact;
      hr = m_pIMessenger->GetContact(bstrSigninName, bstrServiceId, 
                                     (IDispatch**)&pIMessengerContact);
      if (FAILED(hr))
         return NULL;

      return pIMessengerContact;
}

Getting a Contact in JavaScript

var comm = new ActiveXObject("Communicator.UIAutomation");
var contact = GetContact("jaya@contoso.com");

function GetContact(signinUri)
{
   var c = comm.GetContact(signinUri, comm.MyServiceId);
   return c;
   
}

Note

For reasons of security, not all methods or properties can be called using JavaScript or another scripting language. Such restrictions are documented in Office Communicator Automation API Reference.

See Also

Reference

Events