Adds a contact to the group. Not scriptable.

Syntax

HRESULT AddContact(
   [in] VARIANT vContact
);

Parameters

vContact

[in] VARIANT that defines the contact to add to the group.

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_INVALIDARG

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.

E_FAIL

A general failure occurred.

MSGR_E_NOT_LOGGED_ON

The client is offline.

MSGR_E_USER_NOT_FOUND

The user specified to be added does not exist.

Remarks

This method adds one of the local client's existing contacts to a contact group. The method does not create a new contact. It is possible to add a contact to more than one user-defined group. The contact remains a member of the default "Other Contacts" group after the Office Communicator server has added this contact to the specified group. If you are building your own custom contact list, you want to check to see if a contact is a member of one of the local client's user-defined groups before displaying that contact as a member of the "Other Contacts" group. For more information, see Building a Custom Contact List.

Example

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 a method to add the global contact object to that group.

Copy Code
if (communicator != null && gContact != null)
{
   IMessengerGroups myGroups;
   try
   {
	 myGroups = (IMessengerGroups)communicator.MyGroups;
	 if (myGroups != null)
	 {
		foreach (IMessengerGroup myGroup in myGroups)
		{
			myGroup.AddContact(gContact); // global scope contact
	}
	 }
   }
   catch (COMException CGCE)
   {
	Console.WriteLine(CGCE.ErrorCode.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

IMessengerGroup