DotMSN - 取得MSN名單範例

DotMSN - 取得MSN名單範例


using XihSolutions.DotMSN;
using XihSolutions.DotMSN.Core;
using XihSolutions.DotMSN.DataTransfer;
...

Messenger messenger;

public void myConnect()
{
    messenger = new Messenger();
    messenger.Credentials.ClientID = "msmsgs@msnmsgr.com";
    messenger.Credentials.ClientCode = "Q1P7W2E4J9R8U3S5";
    messenger.Nameserver.SignedIn += new EventHandler(Nameserver_SignedIn);
    messenger.Credentials.Account = "*****";
    messenger.Credentials.Password = "****";
    messenger.Connect();
}

void Nameserver_SignedIn(object sender, EventArgs e)
{
    UpdateUI(delegate
    {
        if (!messenger.Connected)
            return;
       
        foreach (Contact contact in messenger.ContactList.All)
        {                   
            listBox1.Items.Add(contact.Mail);                    
        }               
    });

}

private void UpdateUI(EventHandler action)
{
    this.Invoke(action);
}

private void ContactBtn_Click(object sender, EventArgs e)
{
    myConnect();
}