Google 中的开源项目,MSNPSharp,提供了支持。 程序可以从这里下载, http://code.google.com/p/msnp-sharp/
在使用的时候,需要注意这些事件处理程序对于获得MSN连接状态以及进行处理很重要。 messenger.NameserverProcessor.ConnectionEstablished += new EventHandler<EventArgs>(NameserverProcessor_ConnectionEstablished); messenger.Nameserver.AuthenticationError += new EventHandler<ExceptionEventArgs>(Nameserver_AuthenticationError); messenger.Nameserver.ServerErrorReceived += new EventHandler<MSNErrorEventArgs>(Nameserver_ServerErrorReceived); messenger.Nameserver.ExceptionOccurred += new EventHandler<ExceptionEventArgs>(Nameserver_ExceptionOccurred); messenger.Nameserver.SignedIn += new EventHandler<EventArgs>(Nameserver_SignedIn);
if (messenger.Connected) { messenger.Disconnect(); }
// set the credentials, this is ofcourse something every MSNPSharp program will need to implement. messenger.Credentials = new Credentials(LoginEmail, Password, MsnProtocol.MSNP18);
// inform the user what is happening and try to connecto to the messenger network. messenger.Connect();
发布评论
评论(1)
Google 中的开源项目,MSNPSharp,提供了支持。
程序可以从这里下载,
http://code.google.com/p/msnp-sharp/
在使用的时候,需要注意这些事件处理程序对于获得MSN连接状态以及进行处理很重要。
messenger.NameserverProcessor.ConnectionEstablished += new EventHandler<EventArgs>(NameserverProcessor_ConnectionEstablished);
messenger.Nameserver.AuthenticationError += new EventHandler<ExceptionEventArgs>(Nameserver_AuthenticationError);
messenger.Nameserver.ServerErrorReceived += new EventHandler<MSNErrorEventArgs>(Nameserver_ServerErrorReceived);
messenger.Nameserver.ExceptionOccurred += new EventHandler<ExceptionEventArgs>(Nameserver_ExceptionOccurred);
messenger.Nameserver.SignedIn += new EventHandler<EventArgs>(Nameserver_SignedIn);
这里是登录的方法,
private void button1_Click(object sender, EventArgs e)
{
if (messenger.Connected)
{
messenger.Disconnect();
}
// set the credentials, this is ofcourse something every MSNPSharp program will need to implement.
messenger.Credentials =
new Credentials(LoginEmail, Password, MsnProtocol.MSNP18);
// inform the user what is happening and try to connecto to the messenger network.
messenger.Connect();
}
这是列写联系人,联系人昵称(就是你在MSN Messenger中自定义的用户名称)以及电子邮件。
private void Nameserver_SignedIn(object sender, EventArgs e)
{
<coding-2 lang="other">
if (InvokeRequired)
{
BeginInvoke(new EventHandler(Nameserver_SignedIn), sender, e);
return;
}
foreach (Contact contact in messenger.ContactList.All)
{
PrintOut(
contact.Name + " | " +
contact.Mail + " | " +
contact.NickName + "| n");
}
}