Windows Live Messenger API How-To
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
6 posts
Page 1 of 1
Hello and welcome to my tutorial on how to use the Windows Live Messenger API.
Tested and works with MSN 2011
Controls needed
2 Labels, name = lbl_st, text = unknown | name = "Label1", text = "My Status"
Timer1, enabled = true, interval = 100
Textbox1, text = "Email Address"
4 Buttons; text = "Add Contact" | text = "Load Online Contacts" | text = "Sign-out" | text = "Change Status"
Listbox1
Combobox1, items =
First thing you need to do after you create your project is add a reference to the API. Go to "My Project" and click on the "References" tab. Then click on "Add..." and click on "COM" tab and scroll down till you find "Messenger API Type Library", and select it. At the bottom of the same page you will see checkboxed-listbox, scroll down to "MessengerAPI" and check it.


Now you go to your form and import these at the top.
Might not work on some versions of msn. How to login.
Button_click (login) event
Comment, Rate, +rep
Thanks
CodexVideos
Tested and works with MSN 2011
Controls needed
2 Labels, name = lbl_st, text = unknown | name = "Label1", text = "My Status"
Timer1, enabled = true, interval = 100
Textbox1, text = "Email Address"
4 Buttons; text = "Add Contact" | text = "Load Online Contacts" | text = "Sign-out" | text = "Change Status"
Listbox1
Combobox1, items =
Code: Select all
Away
Be Right Back
Busy
Invisible
Offline
On the phone
Online
Out to lunch
Unknown

First thing you need to do after you create your project is add a reference to the API. Go to "My Project" and click on the "References" tab. Then click on "Add..." and click on "COM" tab and scroll down till you find "Messenger API Type Library", and select it. At the bottom of the same page you will see checkboxed-listbox, scroll down to "MessengerAPI" and check it.


Now you go to your form and import these at the top.
Code: Select all
Now after Public Class <form name> add this.
Imports MessengerAPI.MISTATUS
Imports MessengerAPI
Code: Select all
Add this to form_load event:
Public msn As New MessengerAPI.Messenger
Public msnwindow As MessengerAPI.IMessengerWindow = msn.Window
Code: Select all
Add this after/before form_load event:
AddHandler msn.OnMyStatusChange, AddressOf msn_OnMyStatusChange
Control.CheckForIllegalCrossThreadCalls = False
Code: Select all
Button1_click (add contact) event:
If mMyStatus = MISTATUS_AWAY Then
lbl_st.Text = "Away"
ElseIf mMyStatus = MISTATUS_BE_RIGHT_BACK Then
lbl_st.Text = "Be Right Back"
ElseIf mMyStatus = MISTATUS_BUSY Then
lbl_st.Text = "Busy"
ElseIf mMyStatus = MISTATUS_INVISIBLE Then
lbl_st.Text = "Invisible"
ElseIf mMyStatus = MISTATUS_OFFLINE Then
lbl_st.Text = "Offline"
ElseIf mMyStatus = MISTATUS_ON_THE_PHONE Then
lbl_st.Text = "On the phone"
ElseIf mMyStatus = MISTATUS_ONLINE Then
lbl_st.Text = "Online"
ElseIf mMyStatus = MISTATUS_OUT_TO_LUNCH Then
lbl_st.Text = "Out to lunch"
ElseIf mMyStatus = MISTATUS_UNKNOWN Then
lbl_st.Text = "Unknown"
End If
Code: Select all
Button2_click (Change status) event:
Try
If Not TextBox1.Text = "Email Address" Then
msn.AddContact(0, TextBox1.Text)
End If
Catch ex As Exception
End Try
Code: Select all
Button3_click (load online contacts) event:
Try
If ComboBox1.SelectedItem = "Away" Then
msn.MyStatus = MISTATUS_AWAY
ElseIf ComboBox1.SelectedItem = "Be Right Back" Then
msn.MyStatus = MISTATUS_BE_RIGHT_BACK
ElseIf ComboBox1.SelectedItem = "Busy" Then
msn.MyStatus = MISTATUS_BUSY
ElseIf ComboBox1.SelectedItem = "Invisible" Then
msn.MyStatus = MISTATUS_INVISIBLE
ElseIf ComboBox1.SelectedItem = "Offline" Then
msn.MyStatus = MISTATUS_OFFLINE
ElseIf ComboBox1.SelectedItem = "On the phone" Then
msn.MyStatus = MISTATUS_ON_THE_PHONE
ElseIf ComboBox1.SelectedItem = "Online" Then
msn.MyStatus = MISTATUS_ONLINE
ElseIf ComboBox1.SelectedItem = "Out to lunch" Then
msn.MyStatus = MISTATUS_OUT_TO_LUNCH
ElseIf ComboBox1.SelectedItem = "Unknown" Then
msn.MyStatus = MISTATUS_UNKNOWN
End If
Catch ex As Exception
End Try
Code: Select all
Listbox1_doubleclick event:
Dim contacts As IMessengerContacts = msn.MyContacts
Dim contact As IMessengerContact
ListBox1.Items.Clear()
For Each contact In contacts
If Not contact.Status = MISTATUS.MISTATUS_OFFLINE Then
ListBox1.Items.Add(contact.FriendlyName)
End If
Next
Code: Select all
Button4_click (sign-out) event:
Dim contacts As IMessengerContacts = msn.MyContacts
Dim vContact As IMessengerContact
For Each Contact As IMessengerContact In contacts
If ListBox1.SelectedItem = Contact.FriendlyName Then
vContact = msn.GetContact(Contact.SigninName, Contact.ServiceId)
End If
Next
msn.InstantMessage(vContact)
Code: Select all
Timer1_tick event:
msn.Signout()
Code: Select all
*BONUS* If msn.MyStatus = MISTATUS_AWAY Then
lbl_st.Text = "Away"
ElseIf msn.MyStatus = MISTATUS_BE_RIGHT_BACK Then
lbl_st.Text = "Be Right Back"
ElseIf msn.MyStatus = MISTATUS_BUSY Then
lbl_st.Text = "Busy"
ElseIf msn.MyStatus = MISTATUS_INVISIBLE Then
lbl_st.Text = "Invisible"
ElseIf msn.MyStatus = MISTATUS_OFFLINE Then
lbl_st.Text = "Offline"
ElseIf msn.MyStatus = MISTATUS_ON_THE_PHONE Then
lbl_st.Text = "On the phone"
ElseIf msn.MyStatus = MISTATUS_ONLINE Then
lbl_st.Text = "Online"
ElseIf msn.MyStatus = MISTATUS_OUT_TO_LUNCH Then
lbl_st.Text = "Out to lunch"
ElseIf msn.MyStatus = MISTATUS_UNKNOWN Then
lbl_st.Text = "Unknown"
End If
Might not work on some versions of msn. How to login.
Button_click (login) event
Code: Select all
There are many more features you can do, just try it yourself.msn.Signin(0, "USERNAME", "PASSWORD")
Comment, Rate, +rep

Thanks
CodexVideos
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
I get this error when I try to make a new instance of MessengerAPI.Messenger: Creating an instance of the COM component with CLSID {B69003B3-C55E-4B48-836C-BC5946FC3B28} from the IClassFactory failed due to the following error: 8007000e.
I have windows live messenger installed.
I have windows live messenger installed.
mandai wrote:I get this error when I try to make a new instance of MessengerAPI.Messenger: Creating an instance of the COM component with CLSID {B69003B3-C55E-4B48-836C-BC5946FC3B28} from the IClassFactory failed due to the following error: 8007000e.Is this your error : System.OutOfMemoryException
I have windows live messenger installed.
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
mandai wrote:I get this error when I try to make a new instance of MessengerAPI.Messenger: Creating an instance of the COM component with CLSID {B69003B3-C55E-4B48-836C-BC5946FC3B28} from the IClassFactory failed due to the following error: 8007000e.
I have windows live messenger installed.
I think you need to be logged off of msn and then leave msn open,it worked for me!
mandai wrote:I don't see any OutOfMemoryException messages.I did a simple Google Search for
CLSID {B69003B3-C55E-4B48-836C-BC5946FC3B28} error code.
It is amazing what you can find out when you know how to using the internet. :)
This link in the MSDN forums mentioned something about the program my be incompatible with your system.
It recommends all sorts of fixes. Mostly editing your Registry.
http://social.msdn.microsoft.com/Forums ... 0270238aca
Now this post on C# Sharpcorner ( scroll down to the bottom of the page and reead some of the feedbacks) state that this code may only work with MSN Messenger 8.1 and NOT Windows Live Messenger. I do believe
that these 2 software are completely different from each other.
http://www.c-sharpcorner.com/uploadfile ... enger.aspx
But in my humble opinion the CLSID is a registry error code. So I would tend to think you could start there.
CLSID {B69003B3-C55E-4B48-836C-BC5946FC3B28}
BTW, this is no way pointed at you personally.
I figured I would do a Google Search and see what pops up.
Like I said, " I was amazed at what I found."
Scottie1972
6 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023