Adds a contact to the contact list without prompting or notification UI. Not scriptable.
Syntax
HRESULT AddContact( [in] BSTR bstrSiginName, [in] VARIANT vService ); |
Parameters
- bstrSiginName
-
[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.
- vService
-
[in] VARIANT that defines the service. For more information, see "Remarks."
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 contact is added to the contacts list.
- E_POINTER
-
The bstrSiginName parameter resolved to a null value.
- E_INVALIDARG
-
The bstrSiginName parameter is not valid for this method.
- MSGR_E_NOT_LOGGED_ON
-
The service is not logged on.
Remarks
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.
Example
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.
Copy Code | |
---|---|
CommunicatorPrivate.MessengerPrivClass msgrPrivClass = new MessengerPrivClass(); string communicatorServiceID = communicator.MyServiceId; if (msgrPrivClass != null) { try { msgrPrivClass.AddContact("PernilleH@contoso.com", communicatorServiceID); } catch (COMException CE) { Console.WriteLine(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
-
Msgrpriv.idl