This documentation is archived and is not being maintained.


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.

Adds a contact to the contact list without prompting or notification UI. Not scriptable.

HRESULT AddContact(
   [in] BSTR bstrSiginName,
   [in] VARIANT vService


[in] BSTR that defines the sign-in name of the contact to be added. The method runs regardless of whether this parameter is valid. The DMessengerPrivateEvents::OnContactListAdd event contains the results from this method call.


[in] VARIANT that defines the service. For more information, see "Remarks."

Returns one of the following values. For managed code applications, these return values are received in the form of a COMException.


The contact is added to the contacts list.


The bstrSiginName parameter resolved to a null value.


The bstrSiginName parameter is not valid for this method.


The service is not logged on.

The vService parameter can be specified as a BSTR containing the ID (not the name) of the service, or it can also be a pointer to an IDispatch an IMessengerServices::PrimaryService object.

The example code creates a new instance of an IMessengerPrivate class by calling the constructor for the class. Using a previously instantiated IMessenger object, the example code obtains the service ID of the primary Communicator service. This service ID is passed as a parameter to the AddContact method so that the contact is associated to the desired Communicator service.

CommunicatorPrivate.MessengerPrivClass msgrPrivClass = new MessengerPrivClass();

string communicatorServiceID = communicator.MyServiceId;
if (msgrPrivClass != null)
      msgrPrivClass.AddContact("", communicatorServiceID);
   catch (COMException CE)


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


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


Microsoft Office Communicator 2007 Automation API

IDL file




Other Resources

IMessengerPrivate::EnableAlertEvents Method