Share via


IUccIncomingInstantMessageEvent.ContentType Property

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.

Gets the content type of the incoming instant message.

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

Syntax

'Declaration
ReadOnly Property ContentType As String
string ContentType { get; }
property String^ ContentType {
    String^ get ();
}
/** @property */
String get_ContentType ()
function get ContentType () : String

Property Value

A value of the BSTR* (string, for a .NET application) type.

Remarks

The ContentType property indicates the formatting rules a client should apply to the string value of the Content text property. The content type is set by a remote client whose responsibility it is to fill the content property of a message with text of the correct format. A Unified Communications server does not validate the content of a message against the specified content type. Regardless of the ContentType specified, the value of the Content property can be treated as a simple text string.

Win32 COM/C++ Syntax

HRESULT get_ContentType
(
   BSTR* pVal
);

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 can be called by client code that implements a TextBox control within a UI designed to provide instant messaging functionality. The example method is called by the application OnInstantMessageReceived event handler. The Content property string is appended to the TextBox instance that is passed to the example method by reference.

The ContentType property is read and matched against the MIME content type of "text/plain" to determine whether the incoming message text is to be displayed in a text box instead of a rich text box control.

/// <summary>
/// Appends received text to the end of a text box, scrolls
/// the text box if necessary, and moves selection curser to bottom of box 
/// </summary>
/// <param name="pIMEvent">UccIncomingInstantMessageEvent received in OnInstantMessageReceived</param>
/// <param name="pBoxToFill"></param>
/// <returns></returns>
private void ProcessIncomingIM(
    UccIncomingInstantMessageEvent pIMEvent, 
    ref TextBox pBoxToFill,
    ref RichTextBox pRichBoxToFill)
{
    if (pIMEvent.ContentType == "text/plain")
    {
        pBoxToFill.AppendText(System.Environment.NewLine);
        pBoxToFill.AppendText(
            pIMEvent.ParticipantEndpoint.Participant.Uri.User + ": ");
        pBoxToFill.AppendText(pIMEvent.Content);

        //select bottom of textbox;
        pBoxToFill.ScrollToCaret();
        pBoxToFill.Refresh();
    }
    else if (pIMEvent.ContentType == "text/enriched")
    { 
        // update rich text box
    }
    else if (pIMEvent.ContentType == "text/html")
    {
        //update a browser control
    }

}

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

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