public void Evaluate(int SpreadMax) { double dblrefresh; this.FPinInRefresh.GetValue(0, out dblrefresh); if (dblrefresh >= 0.5) { string host, username, pwd; double dblport, dblcount; this.FPinInHost.GetString(0, out host); this.FPinInPort.GetValue(0, out dblport); this.FPinInUsername.GetString(0, out username); this.FPinInPassword.GetString(0, out pwd); this.FPinInCount.GetValue(0, out dblcount); Higuchi.Net.Pop3.Pop3Client client = new Higuchi.Net.Pop3.Pop3Client(); client.ServerName = host; client.Port = Convert.ToInt32(dblport); client.UserName = username; client.Password = pwd; if (client.Authenticate()) { long Count = client.GetTotalMessageCount(); int max = Math.Min(Convert.ToInt32(dblcount), Convert.ToInt32(Count)); this.FPinOutSubject.SliceCount = max; this.FPinOutBody.SliceCount = max; this.FPinOutFrom.SliceCount = max; long idx = Count; for (int i = 0; i < max; i++) { Higuchi.Net.Pop3.Pop3Message msg = client.GetMessage(idx); this.FPinOutFrom.SetString(i, msg.From); this.FPinOutSubject.SetString(i, msg.Subject); this.FPinOutBody.SetString(i, msg.BodyText); idx--; } } else { this.FHost.Log(TLogType.Error, "Authentication failed"); this.FPinOutBody.SliceCount = 0; this.FPinOutSubject.SliceCount = 0; this.FPinOutFrom.SliceCount = 0; } } }
void updateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { _updateTimer.Stop(); lock (_emailLock) { _client = new Higuchi.Net.Pop3.Pop3Client(); _client.UserName = ClientUserName; _client.Password = ClientPassword; _client.ServerName = PopServer; _client.Port = PopPort; _client.Ssl = true; _client.ReceiveTimeout = 30000; _client.Authenticate(); long mailCount = _client.GetTotalMessageCount(); if (mailCount > _previousMailCount) { for (long i = _previousMailCount + 1; i <= mailCount; i++) { Higuchi.Net.Pop3.Pop3Message message = _client.GetMessage(i); if (message.To == ClientEmailAddress && message.From == ServerEmailAddress && message.Subject == "TunnelProxy") { List <Higuchi.Net.Pop3.Pop3Content> l = Higuchi.Net.Pop3.Pop3Message.GetAttachedContents(message); MemoryStream dataStream = new MemoryStream(10000); l[0].DecodeData(dataStream, false); dataStream.Flush(); byte[] data = dataStream.ToArray(); //byte[] data = ConversionUtils.ConvertToBytes(l[0].BodyText); //string body = message.BodyText; //if (body.EndsWith("\r\n\r\n")) // body = body.Substring(0, body.Length - 4); //byte[] data = ConversionUtils.ConvertToBytes(body); if (DataReceived != null) { DataReceived(this, new DataReceivedEventArgs(data)); } } } _previousMailCount = mailCount; } } _updateTimer.Start(); }