Indicates that the Office Communicator server has processed a request to add a contact to a group. Not scriptable.

Syntax

void OnContactAddedToGroup(
   [in] LONG hr,
   [in] IDispatch* pMGroup,
   [in] IDispatch* pMContact
);

Parameters

hr

[in] Success or error code as a LONG.

For a table of the MSGR_E_* constants, see Error Codes.

Returns one of the following values:

  • S_OK. A user is successfully added to the group.

  • MSGR_E_USER_NOT_FOUND. The user specified to be added does not exist.

  • MSGR_E_GROUP_DOES_NOT_EXIST. The group specified is not found.

pMGroup

[in] Pointer to an IDispatch interface on the IMessengerGroup object indicating the group to which the contact is added.

pMContact

[in] Pointer to an IDispatch interface on the IMessengerContact object indicating the added contact.

Return Value

The implementer of this event handler will determine what value should be returned.

Remarks

This event is used to notify the client application that the Office Communicator server has attempted to add a contact to the client contact list. If the hr parameter indicates success, the client application should add the contact to the local application contact list. The request to add a contact to the list is made by the local user but the action is performed by the Office Communicator server. If the client application is keeping a current list of contacts, this event handler can be used to trigger the update of the client list.

Example

The example code creates IMessengerContact and IMessengerGroup objects from the event arguments by casting the objects into the appropriate types. After casting, all of the methods and properties of the types are available.

The myContactList object referenced in the example snippet is a custom contact list created and maintained by the example application.

Copy Code
void communicator_OnContactAddedToGroup(
	 int hr, 
	 object pMGroup, 
	 object pMContact)
{
	if (hr == 0)
	{
		IMessengerContact imContact = (IMessengerContact)pMContact;
		IMessengerGroup Mgroup = (IMessengerGroup)pMGroup;
		StringBuilder sb = new StringBuilder();
		sb.Append(
		 " CONTACT ADDED TO GROUP: HRESULT-" +
		 formReturnErrors.returnComError(hr));

		sb.Append(
		 " Group: " +
		 Mgroup.Name);

		sb.Append(
		 " Contact:" +
		 imContact.FriendlyName);

		Console.WriteLine(
			 "EVENT: " +
			 sb.ToString());
		// update custom contact list if exists
		if (myContactList != null)
			myContactList.loadContactList();
}
}

Requirements

Server

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

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

Product

Microsoft Office Communicator 2007 Automation API

IDL file

Msgrua.idl

Server

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

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

See Also