public void ReceiveMails(string Username,int OrderID) { //jmail.Message Msg=new jmail.Message(); //jmail.POP3 jpop = new jmail.POP3(); if(OrderID!=0) { SqlDataReader dataReader = this.ExtGetSetting(Username,OrderID); if(dataReader.Read()) { if(dataReader["PopServer"].ToString()!=""&&dataReader["PopUsername"].ToString()!="") { //jpop.Connect(dataReader["PopUsername"].ToString(),dataReader["PopPassword"].ToString(),dataReader["PopServer"].ToString(),Int32.Parse(dataReader["PopPort"].ToString())); Pop3Client cl = new Pop3Client(dataReader["PopServer"].ToString()); cl.UserName = dataReader["PopUsername"].ToString(); cl.Password = dataReader["PopPassword"].ToString(); cl.Port = Int32.Parse(dataReader["PopPort"].ToString()); try { if (cl.Authenticate()) { long mailCount = cl.GetTotalMessageCount(); for (int i = 1; i <= mailCount; i++) { this.SaveExtMail(cl.GetMessage(i), Username, dataReader["Email"].ToString()); } } } catch (Exception eX) { throw eX; } finally { cl.Close(); } } } } }
private void TestPopConn(string PopServer,string Uname,string Pwd,string Port,int OrderID) { long Count; //jmail.Message Msg=new jmail.Message(); //jmail.POP3 jpop = new jmail.POP3(); Pop3Client cl = new Pop3Client(PopServer); cl.UserName = Uname; cl.Password = Pwd; cl.Ssl = false; cl.Port = int.Parse(Port); try { //jpop.Connect(Uname,Pwd,PopServer,Int32.Parse(Port)); if (cl.Authenticate()) { //Count = jpop.Count; Count = cl.GetTotalMessageCount(); switch (OrderID) { case 1: this.lblResultRep1.Visible = true; this.lblResultRep1.Text = "���Գɹ�,���� " + Count.ToString() + " ���ʼ�"; break; case 2: this.lblResultRep2.Visible = true; this.lblResultRep2.Text = "���Գɹ�,���� " + Count.ToString() + " ���ʼ�"; break; case 3: this.lblResultRep3.Visible = true; this.lblResultRep3.Text = "���Գɹ�,���� " + Count.ToString() + " ���ʼ�"; break; default: break; } //jpop.Disconnect(); cl.Close(); } } catch(Exception e) { switch (OrderID) { case 1: this.lblResultRep1.Visible = true; this.lblResultRep1.Text = "δ�����ӵ���ָ����[�����ʼ�������],�������˴����[�û���]��[����]��"; break; case 2: this.lblResultRep2 .Visible = true; this.lblResultRep2.Text = "δ�����ӵ���ָ����[�����ʼ�������],�������˴����[�û���]��[����]��"; break; case 3: this.lblResultRep3 .Visible = true; this.lblResultRep3.Text = "δ�����ӵ���ָ����[�����ʼ�������],�������˴����[�û���]��[����]��"; break; default: break; } } }