Removes an IMessengerGroup object from a collection. Not scriptable.

Syntax

HRESULT Remove(
   [in] IDispatch* pGroup
);

Parameters

pGroup

[in] Pointer to the IDispatch interface on a MessengerGroup 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 pGroup is not in the collection (as determined locally by the client).

E_POINTER

pGroup is a null pointer.

E_NOTIMPL

The method cannot be accessed through scripting.

MSGR_E_CANNOT_DELETE

The group "Other Contacts" is read-only and cannot be deleted.

Remarks

The Remove method takes an IMessengerGroup interface object as a parameter. The group object can be retrieved for removal by getting the collection of groups belonging to the local client. When the group collection is successfully instantiated, you can iterate over the group to find the group to be removed. If you know the group to be removed by its position in the collection, you can use the IMessengerGroups::Item method to retrieve the group for removal. This method represents a request to remove a group from the local client's user store on the Office Communicator server. The local client application should register an event handler for the DMessengerEvents::OnGroupRemoved event so that it can be notified that the action succeeded. When the event is received, the group should be removed from the contact list. The contacts associated to the group are not deleted. Instead, they are reassociated with the default group "Other Contacts".

Note:
To add a group to the collection of groups, call IMessenger2::CreateGroup. The IMessengerGroups interface does not contain a method for adding to the collection.

Example

This example code takes a count of the groups belonging to the local client. The last group in the collection is then deleted.

Copy Code
communicator.OnGroupRemoved += new DMessengerEvents_OnGroupRemovedEventHandler(communicator_OnGroupRemoved);
...
try
{
   IMessengerGroups theseGroups = 
				 (IMessengerGroups)communicator.MyGroups;
   IMessengerGroup thisGroup = 
			(IMessengerGroup)theseGroups.Item(theseGroups.Count - 1);
   if (thisGroup != null)
   {
	theseGroups.Remove(thisGroup);
   }
}
catch (COMException ICE)
{
   resultsText.Text = formReturnErrors.returnComError(ICE.ErrorCode);
}
...
void communicator_OnGroupRemoved(int hr, object pMGroup)
{
  //If the custom contact list has been instantiated, it needs 
  //to be updated on the removal of the contact group.
  if (myContactList != null)
	 myContactList.loadContactList();
  }

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

IMessengerGroups