IMessengerContacts::Remove

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.

Removes an IMessengerContact object from a collection. Not scriptable.

Syntax

HRESULT Remove(
   [in] IDispatch* pMContact
);

Parameters

  • pMContact
    [in] Pointer to an IDispatch interface on an IMessengerContact object to be removed from the collection.

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.
  • E_FAIL
    The object pointed to by pMContact is not in the collection (as determined locally by the client).
  • E_POINTER
    pMContact is a null pointer.
  • E_NOTIMPL
    Cannot be accessed through scripting.

Remarks

If this method is successful (returns S_OK), invoking this method results in a DMessengerEvents::OnContactListRemove event. This event includes any errors generated by the server, including MSGR_E_USER_NOT_FOUND, on an attempt to remove an IMessengerContact object that did not exist in a list. For managed code applications, passing a null pointer to a contact object raises a synchronous ArgumentException exception that must be caught.

Contacts can be restored to the contact list by retrieving the contact from the "Recent Contacts" store in the local machine registry. For more information, see Adding and Removing Contacts from the List.

Example

This code fragment assumes a cocreatable Messenger object has been instantiated and a user has been signed in to a running Office Communicator. The contactToRemove is a pointer to an IDispatch interface on the IMessengerContact object. The call to the remove method raises an event asynchronously with the result of the call only if a synchronous exception is not raised by the initial call. For example, if the contactToRemove object is null when the call is made. For the purposes of this example, the code does not attempt to discover the state of contactToRemove before calling the remove method.

// create a contact list object for signed in user
IMessengerContacts messengerContacts = (IMessengerContacts)messenger.MyContacts;

try
{
   messengerContacts.Remove(contactToRemove);
}
catch (ArgumentException)
{
   Console.WriteLine("Invalid Argument");
}
catch (COMException ce)
{ 
    Console.WriteLine(ce.ErrorCode.ToString() + " Message: " + CE.message.Trim());
}

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

Other Resources

IMessengerContacts