/// <summary> /// 获取邮件通过lumisoft /// </summary> /// <param name="pop3Server">邮件服务器</param> /// <param name="username">用户名</param> /// <param name="password">密码</param> /// <returns>邮件链表</returns> public List<Mime> GetEmails(string pop3Server, string username, string password) { //string pop3Server = ""; //邮箱服务器 int pop3Port = 110; //端口号码 bool pop3UseSsl = false; //string username = ""; //邮箱用户名 //string password = ""; //邮箱密码 List<string> gotEmailIds = new List<string>(); List<Mime> result = new List<Mime>(); using (POP3_Client pop3 = new POP3_Client()) { try { //与Pop3服务器建立连接 pop3.Connect(pop3Server, pop3Port, pop3UseSsl); //验证身份 pop3.Authenticate(username, password, false); //获取邮件信息列表 POP3_ClientMessageCollection infos = pop3.Messages; //int i = 0; foreach (POP3_ClientMessage info in infos) { //每封Email会有一个在Pop3服务器范围内唯一的Id,检查这个Id是否存在就可以知道以前有没有接收过这封邮件 //if (i==3) //{ // break; //} if (gotEmailIds.Contains(info.UID)) continue; //获取这封邮件的内容 byte[] bytes = info.MessageToByte(); //记录这封邮件的Id gotEmailIds.Add(info.UID); //解析从Pop3服务器发送过来的邮件信息 Mime mime = Mime.Parse(bytes); result.Add(mime); // i++; } //this.DeleteMail(pop3Server, pop3Port.ToString(), username, password);//删除邮件服务器上面的邮件 } catch (Exception ex) { throw new Exception(ex.Message); } } return result; }