IMessenger::MyContacts

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.

Retrieves the contact list that is contained in the client or Messenger object. The retrieved list is a MessengerContacts collection object that can be manipulated with the IMessengerContacts interface. It can be called from a script not running inside a Web page.

Syntax

HRESULT MyContacts(
   [out,
   retval] IDispatch** ppMContacts
);

Parameters

  • ppMContacts
    Return value. Pointer to a pointer to an IDispatch interface. Returns the IMessengerContacts interface on the contact list or MessengerContacts collection object.

Return Value

Returns one of the following values. For managed code applications, these return values are received in the form of a COMException.

  • S_OK
    Success. See Remarks.
  • RPC_X_NULL_REF_POINTER
    ppMContacts is a null pointer.
  • E_FAIL
    An error occurred during the list creation.

Remarks

ppMContacts should be released when it is no longer needed. Retrieved lists can potentially have zero members in their collection.

If this method is called while the client is not signed in, S_OK is still the HRESULT and a true object is returned. However, the resulting MessengerContacts collection object has zero members.

Example

This example code instantiates an IMessengerContacts object and makes a request on the IMessenger object communicator to receive a contact list by calling the IMessenger::MyContacts method. Finally, the code iterates on the contact collection to display each individual contact's friendly name on the application console. For more information about the properties and methods available on a contact, see IMessengerContact.

if (communicator != null)
{
   IMessengerContacts myContacts;
   try
   {
       myContacts = (IMessengerContacts)communicator.MyContacts;
       if (myContacts != null)
       {
           foreach (IMessengerContact myContact in myContacts)
           {
              Console.WriteLine("Contact: " + myContact.FriendlyName);
           }
       }
   }
   catch (COMException CLCE)
   {
      Console.WriteLine(CLCE.ErrorCode.ToString());
   }
}

Requirements

  • Client
    Requires Microsoft DirectX 9.0, C Runtime libraries (msvcm80.dll) on Microsoft Windows© Vista, Microsoft Windows XP Service Pack 1 (SP1) or later, or Microsoft Windows 2000 with Service Pack 4 (SP4). Any Communicator-imposed restrictions apply. .
  • Server
    Requires Microsoft Office Communications Server 2007, AV MCU (for Media Support), Media Relay (for NAT/Firewall traversal) on Microsoft Office Communications Server 2007.
  • Product
    Microsoft Office Communicator 2007 Automation API
  • IDL file
    Msgrua.idl

See Also

Reference

Interfaces