Share via


IMessengerConversationWnd::AddContact

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 another user to the current conversation. Scriptable.

Syntax

HRESULT AddContact(
   [in] VARIANT vContact
);

Parameters

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

  • S_OK
    Success.
  • E_INVALIDARG
    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.
  • E_FAIL
    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.
  • S_FALSE
    The string comparison failed.
  • MSGR_E_SESSION_FULL
    The current conversation window is hosting a voice or video conversation or the maximum number of participants allowed in the session has been reached.

Remarks

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.

Example

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.

imWindow = (IMessengerConversationWnd)communicator.InstantMessage(foundContact);
try
{
  IMessengerContact contactToAdd = (IMessengerContact)communicator.GetContact("jaya@contoso.com", 
                                communicator.MyServiceId
                                )
  if (contactToAdd.IsSelf == false)
     imWindow.AddContact(contactToAdd);
}
catch (COMException CE)
{
   resultsTextBox.Text = "COM Exception " + CE.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

IMessengerConversationWnd