ASP.NET 获取MSN联系人列表
生活随笔
收集整理的這篇文章主要介紹了
ASP.NET 获取MSN联系人列表
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
用到的是 DOTMSN 大家可以從 這里?下到它的代碼....
?
功能很簡單...寫的有點槽了...不過功能是實現了....
?
HTML
<%@?Page?Language="C#"?AutoEventWireup="true"??CodeFile="Default.aspx.cs"?Inherits="_Default"?%><!DOCTYPE?html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Transitional//EN"?"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html?xmlns="http://www.w3.org/1999/xhtml">
<head?runat="server">
????<title>無標題頁</title>
????<style?type="text/css">
????ul{}{?list-style:none;?padding:0;?margin:0;}
????</style>
</head>
<body>
????<form?id="form1"?runat="server">
????<div?align="center">
????????<ul>
????????<li>
????????用戶名:<asp:TextBox?ID="txtUserID"?runat="server"></asp:TextBox>
????????</li>
?????????<li>
?????????密 ?碼:<asp:TextBox?ID="txtPassWd"?TextMode="Password"?runat="server"></asp:TextBox>????
????????</li>
????????</ul>
????????<asp:Button?ID="Button1"?runat="server"?Text="登陸"?onclick="Button1_Click"?/>
????????<br?/>
????????<asp:Label?ID="lblMessage"?runat="server"?Text=""></asp:Label>
????????<br?/>
????????<hr?/>
????????<asp:ListBox?Height="200"?ID="ListBox1"?runat="server"?SelectionMode="Multiple"></asp:ListBox>
????</div>
????</form>
</body>
</html>
?
CS
?
?
using?System;using?System.Configuration;
using?System.Data;
using?System.Linq;
using?System.Web;
using?System.Web.Security;
using?System.Web.UI;
using?System.Web.UI.HtmlControls;
using?System.Web.UI.WebControls;
using?System.Web.UI.WebControls.WebParts;
using?System.Xml.Linq;
using?System.Collections.Generic;
using?XihSolutions.DotMSN;
using?XihSolutions.DotMSN.Core;
using?XihSolutions.DotMSN.DataTransfer;
public?partial?class?_Default?:?System.Web.UI.Page?
{
????private?XihSolutions.DotMSN.Messenger?messenger?=?new?Messenger();
????protected?void?Page_Load(object?sender,?EventArgs?e)
????{
????}
????protected?void?Button1_Click(object?sender,?EventArgs?e)
????{
????????messenger.Credentials.ClientID?=?"msmsgs@msnmsgr.com";
????????messenger.Credentials.ClientCode?=?"Q1P7W2E4J9R8U3S5";
????????try
????????{
????????????if?(messenger.Connected)
????????????{
????????????????lblMessage.Text?=?"Disconnecting?from?server";
????????????????messenger.Disconnect();
????????????}
????????????messenger.Credentials.Account?=?txtUserID.Text;
????????????messenger.Credentials.Password?=?txtPassWd.Text;
????????
????????????lblMessage.Text?=?"Connecting?to?server";
????????????messenger.Connect();
????????????lblMessage.Text?=?"connected?successful";
????????????//網絡傳輸慢所以叫他先睡會,寫的有點糙了。。。不過基本功能實現了。。。
????????????System.Threading.Thread.Sleep(5000);
????????????foreach?(Contact?contact?in?messenger.ContactList.All)
????????????{
????????????????ListItem?item?=?new?ListItem();
????????????????//這個是獲取聯系人?名稱的
????????????????//item.Text?=?contact.Name;
????????????????//這個是獲取聯系人?Mail的
????????????????item.Text?=?contact.Mail;
????????????????ListBox1.Items.Add(item);
????????????}
????????????ListBox1.DataBind();
????????}
????????catch?{?}
????}
}
?
?
您還可以點 這里?下載全部代碼.
轉載于:https://www.cnblogs.com/xiaozhuoyun/archive/2008/07/22/1248820.html
總結
以上是生活随笔為你收集整理的ASP.NET 获取MSN联系人列表的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: FreeSql (三十五)CodeFir
- 下一篇: uni-app—从安装到卸载