Sends a text message to the open conversation window represented by this interface. Not scriptable.
Syntax
HRESULT SendText( [in] BSTR bstrTextMessage ); |
Parameters
- bstrTextMessage
-
A BSTR value representing the text message to be sent to the other participants.
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_FAIL
-
The client is not signed in to the primary service at the time this method is called or the conversation window is closed.
- S_FALSE
-
Cannot bring focus to the window.
Remarks
The conversation window on which this method is invoked can be created by calling the IMessengerAdvanced::StartConversation method. An application can obtain this window object by catching the DMessengerEvents::OnIMWindowCreated event.
Example
The following C# code snippet illustrates how to start an IM conversation window and send a text message to the opened IM window.
Copy Code | |
---|---|
void StartConversation(object[] sipUris) { CommunicatorAPI.IMessengerAdvanced msgrAdv = communicator as CommunicatorAPI.IMessengerAdvanced; communicator.OnIMWindowCreated += new DMessengerEvents_OnIMWindowCreatedEventHandler( communicator_OnIMWindowCreated); if (msgrAdv != null) { try { object obj = msgrAdv.StartConversation( CONVERSATION_TYPE.CONVERSATION_TYPE_IM, sipUris, null, "Testing API", "1", null); imWindowHandle = long.Parse(obj.ToString()); } catch (System.Runtime.InteropServices.COMException ex) { Console.WriteLine(string.Format("{0}", ex.ErrorCode)); } } } // Register for IMWindowCreated event to receive the // conversation window object. Other window objects can // received via this event handling as well. void communicator_OnIMWindowCreated(object pIMWindow) { imWindow = pIMWindow as IMessengerConversationWndAdvanced; SendTextMessage("Hi. You received this message as part of testing the OC API."); } // Send text only if the window object matches the desired // window handle void SendTextMessage(string msg) { if (imWindow == null) return; if (imWindow.HWND == imWindowHandle) { imWindow.SendText(msg); } } |
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