This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Creates a group of IMessengerGroup collection objects. Not scriptable.


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


  • 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
    The client has not enabled groups or the current service does not support groups.
    The new name of the group exceeds the maximum number of characters.
    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.
    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.
    ppGroup is a null pointer.
    The client is not signed in to the primary service at the time this method is called.
    bstrName is null.


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.


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.

IMessengerGroup newGroup;
  newGroup = (IMessengerGroup)communicator.CreateGroup(
                                           "New Contacts", 
catch (COMException CGCE)


  • 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

See Also