组件下载(不包含原文件): http://download.csdn.net/source/496787 使用方法如下: 1、创建一个EmailContacts类 using System; using System.Collections.Generic; using System.Net; using System.Text; using OpenContactsNet; /// <summary> /// 包含获取email联系人的方法 /// </summary> public class EmailContacts { /// <summary> /// 获取email联系人列表 /// </summary> /// <param name="username">email地址</param> /// <param name="password">密码</param> /// <returns></returns> public MailContactList GetContacts(string username, string password) { if (username.Split('@').Length != 2) return null; MailContactList list = null; NetworkCredential credential = new NetworkCredential(username, password); switch (username.Split('@')[1].ToLower()) { case "gmail.com": GmailExtract gmail = new GmailExtract(); gmail.Extract(credential, out list); break; case "yahoo.com": YahooExtract yahoo = new YahooExtract(); yahoo.Extract(credential, out list); break; case "live.com": case "hotmail.com": LiveExtract live = new LiveExtract(); live.Extract(credential, out list); break; default: break; } return list; } }
2、新建webform: getcontacts.aspx getcontacts.aspx.cs using OpenContactsNet; void Page_Load(object sender, EventArgs args) { EmailContacts contacts = new EmailContacts(); MailContactList mails = contacts.GetContacts("username@service.com", "password"); foreach (MailContact mail in mails) { Response.Write("Name: " + mail.Name); Response.Write("Email: " + mail.Email); } }