Introduction to Messenger API Type Library

Windows Live Messenger

Using The MyGroups Property

The property MyGroups needs to be used with the interface called “IMessengerGroups”.

Dim MsgrGroups As IMessengerGroups
Dim MsgrGroup As IMessengerGroup

Set MsgrGroups = objMessenger.MyGroups

The procedures Item and Remove are to be used with the IMessengerGroup interface.

Dim MsgrGroups As IMessengerGroups
Dim MsgrGroup As IMessengerGroup

Set MsgrGroups = objMessenger.MyGroups
Set MsgrGroup = MsgrGroups.Item(Index)

And to remove a group:

Dim MsgrGroups As IMessengerGroups
Dim MsgrGroup As IMessengerGroup

Set MsgrGroups = objMessenger.MyGroups
Set MsgrGroup = MsgrGroups.Item(Index)
Call MsgrGroups.Remove(MsgrGroup)

This will remove the group specified in “Index”, the group must have no contacts in it.

The property Count can be used alone:

Dim MsgrGroups As IMessengerGroups

Set MsgrGroups = objMessenger.MyGroups
Debug.Print MsgrGroups.Count

Adding A Group

Dim MsgrServices As IMessengerServices
Dim MsgrService As IMessengerService

Set MsgrServices = objMessenger.Services
Set MsgrService = MsgrServices.PrimaryService
objMessenger.CreateGroup "Group Name", MsgrService

Putting The Groups in a Listbox

Private Sub LoadGroups()

    Dim MsgrGroups As IMessengerGroups
    Dim MsgrGroup As IMessengerGroup

    Set MsgrGroups = objMessenger.MyGroups

    For Each MsgrGroup In MsgrGroups
        List1.AddItem MsgrGroup.Name
    Next

End Sub

Putting the Contacts in a Listbox Associated with their Group

This loops through each group, in each round of that loop it does another loop, looping the contacts in that group:

Dim MsgrGroups As IMessengerGroups
Dim MsgrGroup As IMessengerGroup
Dim MsgrContacts As IMessengerContacts
Dim MsgrContact As IMessengerContact

Set MsgrGroups = objMessenger.MyGroups

For Each MsgrGroup In MsgrGroups
    Set MsgrContacts = MsgrGroup.Contacts

    For Each MsgrContact In MsgrContacts
        Debug.Print MsgrGroup.Name & " " & MsgrContact.SigninName
    Next

Next

2 Responses to “Introduction to Messenger API Type Library”


  1. 1 Camila

    Hi,

    Do you know….How to add a new item to menu that shows when i right click on a group or a contact?

    thx,

  2. 2 motti

    hi,
    I have trayed to open project and ues the refrens “Messenger API Type library” in c# or visual basic but I cant open the dll file
    dos sam on now what to do?
    Thank motti

Leave a Reply