private bool Conn(string Server, string user, string pass) { try { pop3 = new POP(Server, user, pass, 110); ns = pop3.Connect(); if (pop3.GetNumberOfNewMessages() == "Unable")//如果登录错误 { return(false); } else { return(true); } } catch { return(false); } }
//间隔检测 private void timerS_Tick(object sender, EventArgs e) { NowCout = int.Parse(pop3.GetNumberOfNewMessages());//获取当前邮件数量 //逻辑思维: 获取当前邮件数量 ,如果当前邮件数量大于从前的邮件数量 将逐个检查邮件的内容 检测到符合标准的邮件则执行方法 if (NowCout > OldCount) { nico.ShowBalloonTip(2000, "Qin亲", "亲,有新邮件,请查收", ToolTipIcon.Info); for (int i = OldCount + 1; i <= NowCout; i++) { pop3.readMailInfo(i); string[] temp = pop3.readMailInfo(i); if ((temp[1] == "<" + FromMail + ">" && temp[3].Trim() == FromTitle) || temp[3].Trim() == FromTitle && txtFromMail.Text == "All") { Console.WriteLine("运行进入"); AppRun(); timerS.Stop(); End(); } } OldCount = NowCout;//更新完成 } }