contacts Property
Note: |
|---|
| 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. |
Feature: Messenger.Core
Namespace: Microsoft.Live.Messenger
Each user maintains a contact list that appears in the Windows Live Messenger client. The user subscribes to the contacts in this list and, assuming that these contacts have accepted the user into their allow list, the user can receive the presence status of the contacts and send messages to them. These contacts are contained in the ContactCollection object that is returned by this property.
Usually, contacts that appear on the user's contact list are also allowed to see the user's presence status and are therefore also found in the allowedContacts collection.
The following example uses the contacts property to send a predefined message to all of the user's contacts.
// Get the messenger context and User object.
messengerContext = wl.App.get_messengerContext();
user = messengerContext.get_user();
// Get the user's contact list.
var userContacts = user.get_contacts();
var contactCid;
// Define a message and send it to each contact in the collection.
var message = new Microsoft.Live.Messenger.TextMessage("Hello!");
for (i = 0; i < userContacts.get_count(); i++)
{
var contact = userContacts.get_item(i);
messengerContext.sendMessage(contact.get_cid(), message);
}
Note: