TextMessage Class

Current information about Live Connect is now available in the Windows Live Developer Center. The information in the following sections is provided for legacy purposes only.

Represents a text message.

Script:  http://js.live.net/4.1/loader.js
Feature:  Messenger.Core
Namespace:  Microsoft.Live.Messenger

The JavaScript Library for Windows Live Messenger Connect is built by using the Microsoft Ajax Library. Microsoft Ajax exposes a type system that enables you to add object-oriented capabilities to your JavaScript code. To learn more about creating, instantiating, and deriving from classes, see Creating Custom Client Script by Using the Microsoft Ajax Library.

Microsoft.Live.Messenger.TextMessage = function();


The text message class is used to represent instant messages that are exchanged between the user and the user's contacts. A TextMessage instance associates instant message text with visual formatting information.

An application should create a TextMessage to represent an instant message that the user intends to be delivered to one or more of his or her contacts. If an application needs to send application-specific data to a user's contacts, ApplicationMessage should be used instead.

Messages are sent to and received from contacts via a Conversation. Once an application creates a conversation, it can then send messages to the contacts in the conversation's roster using the sendMessage(Message) method. An application can also register for the messageReceived event to receive notifications for messages that it has received.

The example below demonstrates establishing a conversation with a contact and sending an instant message.

            function onSignInCompleted(sender, e) {
                // Retrieve a contact.
                var contact = _user.get_contacts().find('friend@contoso.com', Microsoft.Live.Messenger.IMAddressType.windowsLive);
                if (contact) {
                    // Create a conversation.
                    var conversation = _user.get_conversations().create(contact.get_currentAddress());
                    // Register for MessageReceived event.
                    // Send an instant message.
                    conversation.sendMessage(new Microsoft.Live.Messenger.TextMessage("Hello friend!"));
            function onMessageReceived(sender, e) {
                alert("Received message: " + e.get_message().get_text());


Windows Live Messenger Connect

Supported in: 4.1

Windows Live Messenger Web Toolkit

Supported in: 3.7, 3.5, 3.1, 3.0, 2.5, 2.0, 1.0

Internet Explorer 8.0, Internet Explorer 7.0, Internet Explorer 6.0, Firefox 3.6, Firefox 3.5, Firefox 3.0, Firefox 2.0, Firefox 1.5, Chrome 4.0, Chrome 3.0, Chrome 2.0, Chrome 1.0, Safari 4.0, Safari 3.0, Opera 10.5