Creates a group of IMessengerGroup collection objects. Not scriptable.

Syntax

HRESULT CreateGroup(
   [in] BSTR bstrName,
   [in] VARIANT vService,
   [out,
   retval] IDispatch** ppGroup
);

Parameters

bstrName

[in] A BSTR that specifies the name of the group to be created.

vService

[in] A VARIANT that can take as its value a VT_BSTR string.

ppGroup

[out, retval] Return value. Pointer to a pointer to an IDispatch interface.

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.

MSGR_E_GROUPS_NOT_ENABLED

The client has not enabled groups or the current service does not support groups.

MSGR_E_GROUP_NAME_TOO_LONG

The new name of the group exceeds the maximum number of characters.

MSGR_E_BAD_GROUP_NAME

The new name of the group is invalid. Characters such as carriage returns, linefeeds, tabs, and nonprintable characters are not allowed. Spaces before and after the group name are trimmed automatically.

E_INVALIDARG

One of the following:

  • bstrName or vService (if VT_BSTR) is a null string or contains nothing but spaces.

  • bstrName or vService (if VT_BSTR) exceeds the maximum number of characters.

  • bstrName or vService (if VT_BSTR) contains a carriage return or linefeed.

RPC_X_NULL_REF_POINTER

ppGroup is a null pointer.

MSGR_E_NOT_LOGGED_ON

The client is not signed in to the primary service at the time this method is called.

E_POINTER

bstrName is null.

Remarks

The IMessenger2::CreateGroup method looks for a group name (bstrName) in the local user list of groups for the service (vService). If not found, the method attempts to create a new group. To check the success of the creation of a new group, use the DMessengerEvents::OnGroupAdded method.

The service parameter (vService) can be a string that contains the service ID, not the name, of the service. The service ID can be obtained from the IMessenger::MyServiceId property.

Example

The example creates a contact group with the name: "New Contacts". The second parameter of the CreateGroup method is required but can be any value. The created newGroup object can be manipulated using the IMessengerGroup interface. For more information, see Managing a Contact Group.

Copy Code
IMessengerGroup newGroup;
try
{
  newGroup = (IMessengerGroup)communicator.CreateGroup(
										 "New Contacts", 
										 "serviceID"
										 );
}
catch (COMException CGCE)
{
	Console.WriteLine(CGCE.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