Récupération des contacts mail MSN avec VB.net 2008 en usant de msnPsharp.dll
Ajouter la référence MsnPsharp.dll au projet, La dll : MsnPSharp
Formulaire :

Nommer :
Le textbox relatif à user (email): TextBox1
Le textbox relatif au mot de passe : TextBox2
Le bouton « connecter » : Button1
Le bouton « deconnecte » : Button2
Une listBox nommée : ListBox1
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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