Adds another user to the current conversation. Scriptable.


HRESULT AddContact(
   [in] VARIANT vContact



[in] VARIANT that can take as its value either a VT_BSTR or a VT_DISPATCH pointer to an existing IMessengerContact object. If the input value type is a string, this method creates a new MessengerContact object internally. The string should be the full sign-in name. If the input value type is a pointer to an existing MessengerContact object (should be type VT_DISPATCH), the existing object is used for contact information.

Return Value

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




One of the following:

  • vContact is null, the wrong type, 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.

  • vContact is VT_BSTR and contains a carriage return or linefeed.


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


The string comparison failed.


The current conversation window is hosting a voice or video conversation or the maximum number of participants allowed in the session has been reached.


This method adds any contact to an existing IM conversation. If the local client is already a participant in the conversation, your code should check the IMessengerContact::IsSelf property before adding the contact. If the boolean property has a true value, the contact should not be added to the conversation.


The example code instantiates an IM conversation with foundContact, an IMessengerContact object. It uses an IMessengerConversationWnd interface object to add an additional contact to a current conversation represented by imWindow. The IMessengerContact parameter of the AddContact method is returned by a call to the IMessenger::GetContact method on the communicator object.

Copy Code
imWindow = (IMessengerConversationWnd)communicator.InstantMessage(foundContact);
  IMessengerContact contactToAdd = (IMessengerContact)communicator.GetContact("", 
  if (contactToAdd.IsSelf == false)
catch (COMException CE)
   resultsTextBox.Text = "COM Exception " + CE.ErrorCode.ToString());



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


See Also