Removes a contact from the group. Not scriptable.


HRESULT RemoveContact(
   [in] VARIANT vContact



[in] VARIANT that can take as its value either a VT_BSTR string or a VT_DISPATCH pointer to an existing IMessengerContact object. If the input value type is a string, this method creates a new MessengerContact object internally. The string should be the full sign-in name. If the input value type is a pointer to an existing MessengerContact object (should be type VT_DISPATCH), the existing object is used.

Return Value

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




One of the following:

  • vContact is null, points to a null string, or points to a string that has a space as the first character.

  • vContact is VT_BStR that exceeded 129 characters (130 if the string terminator is included in the count). This allows for a 64-character sign-in name, @ symbol, and a 64-character domain name. This format does not have to be followed.

  • vContact is VT_BStR and contains a carriage return or linefeed.


A general failure occurred.


The client is offline.


The user specified to be removed does not exist.


This method removes a contact from a user-defined group. The contact itself is not removed from the contact list. When you remove a contact from a user-defined group, the contact appears under the "Other Contacts" group. To remove the contact from the list entirely, use IMessengerContacts::Remove.


The following code example assumes the existence of an IMessengerContact interface object called gContact that represents an individual contact in the logged-on user's contact list. The code instantiates an object called myGroups on the IMessengerGroups interface. It then iterates over the collection of IMessengerGroup objects in the collection. For each contact group in the collection, the code calls RemoveContact to remove the global contact object from that group.

Copy Code
if (communicator != null && gContact != null)
   IMessengerGroups myGroups;
	 myGroups = (IMessengerGroups)communicator.MyGroups;
	 if (myGroups != null)
		foreach (IMessengerGroup myGroup in myGroups)
			myGroup.RemoveContact(gContact); // global scope contact
   catch (COMException CGCE)



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. .


Requires Microsoft Office Communications Server 2007, AV MCU (for Media Support), Media Relay (for NAT/Firewall traversal) on Microsoft Office Communications Server 2007.


Microsoft Office Communicator 2007 Automation API

IDL file


See Also