static void Main(string[] args) { System.Console.WriteLine("Start work"); string sHostPop = "pop.googlemail.com"; string sHostImap = "imap.googlemail.com"; int nPort = 995; string sUserName = "******"; string sPasword = "theSimpsons"; try { string sEml = @"E:\ut8_encripted_teamlab.eml"; ActiveUp.Net.Mail.Message m = ActiveUp.Net.Mail.Parser.ParseMessageFromFile(sEml); var header = ActiveUp.Net.Mail.Parser.ParseHeader(sEml); Pop3Client pop = new Pop3Client(); // Connect to the pop3 client pop.ConnectSsl(sHostPop, nPort, "recent:" + sUserName, sPasword); if (pop.MessageCount > 0) { ActiveUp.Net.Mail.Message message = pop.RetrieveMessageObject(4); string sHtml = message.BodyHtml.Text; } else System.Console.WriteLine("No letters!"); pop.Disconnect(); Imap4Client imap = new Imap4Client(); imap.ConnectSsl(sHostImap, 993); imap.Login(sUserName, sPasword); Mailbox inbox = imap.SelectMailbox("inbox"); if (inbox.MessageCount > 0) { ActiveUp.Net.Mail.Message message = inbox.Fetch.MessageObject(6); string sHtml = message.BodyHtml.Text; } imap.Disconnect(); } catch (Exception ex) { System.Console.Write("\r\n" + ex); } System.Console.WriteLine("Stop work"); System.Console.ReadKey(); }
private void _bRetriveMessage_Click(object sender, EventArgs e) { // We instantiate the pop3 client. Pop3Client pop = new Pop3Client(); try { this.AddLogEntry(string.Format("Connection to the pop 3 server : {0}", _tbPop3Server.Text)); // Connect to the pop3 client pop.ConnectSsl(_tbPop3Server.Text, _tbUserName.Text, _tbPassword.Text); if (pop.MessageCount > 0) { // Retrieve the first message ActiveUp.Net.Mail.Message message = pop.RetrieveMessageObject(1); this.AddLogEntry(string.Format("Subject: {0} From :{1} Message Body {2}" , message.Subject, message.From.Email, message.BodyText)); } else { this.AddLogEntry("There is no message in this pop3 account"); } } catch (Pop3Exception pexp) { this.AddLogEntry(string.Format("Pop3 Error: {0}", pexp.Message)); } catch (Exception ex) { this.AddLogEntry(string.Format("Failed: {0}", ex.Message)); } finally { if (pop.IsConnected) { pop.Disconnect(); } } }