Tuto
MSN contacts with VB.net 2008, we use msnPsharp.dll
Add MsnPsharp.dll référence to the projet, dll : MsnPSharp
Form :
user (email): TextBox1
Password: TextBox2
« connecter » : Button1
« deconnecte » : Button2
listBox : ListBox1
Code :
MSN contacts with VB.net 2008, we use msnPsharp.dll
Add MsnPsharp.dll référence to the projet, dll : MsnPSharp
Form :
user (email): TextBox1
Password: TextBox2
« connecter » : Button1
« deconnecte » : Button2
listBox : ListBox1
Code :
VB.NET:
Imports MSNPSharp
Imports MSNPSharp.Core
Public Class Form1
Dim c As New Messenger
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _ System.EventArgs) Handles Button1.Click
c.Credentials = New Credentials(Me.TextBox1.Text, Me.TextBox2.Text, MsnProtocol.MSNP18, "MSNP18", MsnProtocol.MSNP18)
c.Connect()
Threading.Thread.Sleep(2000)
AddHandler c.Nameserver.SignedIn, AddressOf contlist
End Sub
Private Sub contlist(ByVal sender As Object, ByVal e As EventArgs)
If InvokeRequired = True Then
Invoke(New EventHandler(AddressOf contlist), sender, e)
Return
End If
For Each cont As Contact In c.ContactList.All
Dim t As String = cont.Mail
Me.ListBox1.Items.Add(t)
Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As _ System.EventArgs) Handles Button2.Click
c.Disconnect()
End Sub
End Class