_IUccInstantMessagingSessionEvents.OnSendMessage Method

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.

Raised when a instant message is sent successfully.

Namespace: Microsoft.Office.Interop.UccApi
Assembly: Microsoft.Office.Interop.UccApi (in microsoft.office.interop.uccapi.dll)

Syntax

'Declaration
Sub OnSendMessage ( _
    pEventSource As UccInstantMessagingSession, _
    pEventData As UccSessionOperationEvent _
)
void OnSendMessage (
    UccInstantMessagingSession pEventSource,
    UccSessionOperationEvent pEventData
)
void OnSendMessage (
    UccInstantMessagingSession^ pEventSource, 
    UccSessionOperationEvent^ pEventData
)
void OnSendMessage (
    UccInstantMessagingSession pEventSource, 
    UccSessionOperationEvent pEventData
)
function OnSendMessage (
    pEventSource : UccInstantMessagingSession, 
    pEventData : UccSessionOperationEvent
)

Parameters

Remarks

A successfully sent instant message is a message that was delivered to a remote session endpoint. For various reasons, the remote user may not "receive" the message even when the local user's OnSendMessage event data may indicate success. For example, the remote client may not have advised for _IUccInstantMessagingSessionParticipantEvents on the participants in the session participant collection. In this case, the remote client does not raise OnInstantMessageReceived when the local user's message has been delivered to the remote user endpoint.

The remote participant connection state is still UCC_SESSION_ENTITY_STATE. UCCSES_CONNECTED although the remote user is not actively involved in the instant messaging session. In the event the remote participant disconnects from the session (UCCSES_DISCONNECTED), the local participant's instance of the instant messaging session is set to a state that does not allow further composing status or messages to be sent.

Win32 COM/C++ Syntax

HRESULT OnSendMessage
(
   IUccInstantMessagingSession* pEventSource,
   IUccSessionOperationEvent* pEventData
);

Note

In a Win32 application, the return value of a method or property is always an HRESULT value indicating the status of the call to the interface member. Any result of the operation is returned as a parameter marked with the [out, retval] attribute. In contrast, in a .NET application the HRESULT value indicating an error condition is returned as a COM exception and the [out, retval] parameter becomes the return value. For the UCC API-defined HRESULT values, see Trace and Handle Errors in Unified Communications Client API .

Example

The following example handles the OnSendMessage event by iterating on the session participant operation event collection returned in pEventData.ParticipantResults. Each individual participant result is examined for status information. The extracted status information for each participant is displayed on the local user's system console.

/// <summary>
/// Handler for event raised when local client has sent
/// an instant message to one or more remote clients
/// </summary>
/// <param name="pEventSource">IUccInstantMessagingSession originating session</param>
/// <param name="pEventData">IUccSessionOperationEvent session related event data</param>
void _IUccInstantMessagingSessionEvents.OnSendMessage(
    UccInstantMessagingSession pEventSource, 
    UccSessionOperationEvent pEventData)
{
    StringBuilder sb = new StringBuilder();
    foreach (IUccSessionParticipantOperationEvent participantOpEvent in pEventData.ParticipantResults)
    {
        IUccOperationProgressEvent opProgress = participantOpEvent.Result;
        if (opProgress.IsComplete == true)
        {
            sb.Append("Sent to: " + participantOpEvent.ParticipantEndpoint.Uri.AddressOfRecord);
            sb.Append(System.Environment.NewLine);

            sb.Append("send complete");
            sb.Append(System.Environment.NewLine);

            sb.Append("Status Code: " + opProgress.StatusCode.ToString());
            sb.Append(System.Environment.NewLine);
            sb.Append("Status text: " + opProgress.StatusText);
            Console.WriteLine(sb.ToString());
        }
        sb.Remove(0, sb.Length);
    }
}

Thread Safety

All public static (Shared in Visual Basic) members of this type are thread-safe. Instance members are not guaranteed to be thread-safe.

Platforms

Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2000 with Service Pack 4, Windows Server 2003, Windows Vista Ultimate Edition, Windows Vista Business Edition, Windows Vista Enterprise Edition

Target Platforms

See Also

Reference

_IUccInstantMessagingSessionEvents Interface
_IUccInstantMessagingSessionEvents Members
Microsoft.Office.Interop.UccApi Namespace