Inheritance: System.Net.Sockets.TcpClient
        public IList<MailMessage> GetMailMessagesOfAccount(MailboxAccount account)
        {
            Pop3Client client = null;
            IList<MailMessage> messages = null;

            try
            {
                client = new Pop3Client(account.Username, account.Password, account.Server);
                client.OpenInbox();

                messages = new List<MailMessage>();

                while (client.NextEmail())
                {

                    MailMessage message = new MailMessage() { Id = client.Date.Ticks.ToString(), To = client.To, From = client.From, Subject = client.Subject, Body = client.Body, Date=client.Date };
                    if (client.ContentType != null)
                    {
                        message.Format = client.ContentType.ToLower().Contains("html") ? MailMessageFormat.Html : MailMessageFormat.Text;
                        message.ContentType = client.ContentType;
                    }
                    else
                    {
                        message.Format = MailMessageFormat.Text;
                        message.ContentType = string.Empty;
                    }
                    messages.Add(message);
                }
            }
            finally
            {
                client.CloseConnection();
            }
            return messages;
        }
        public void DeleteMailMessageOfAccountById(MailboxAccount account, string messageId)
        {
            Pop3Client client = null;

            try
            {
                client = new Pop3Client(account.Username, account.Password, account.Server);
                client.OpenInbox();

                while (client.NextEmail())
                {
                    string id = client.Date.Ticks.ToString();
                    bool result = client.DeleteEmail();
                    if (!result)
                    {
                        throw new ApplicationException("Mail message not deleted");
                    }
                }
            }

            finally
            {
                client.CloseConnection();
            }
        }
Example #3
0
            public void run()
            {
                try
                {
                    Pop3Client client = new Pop3Client("callback", "certify588", "proxy.rlanders.com");
                    client.OpenInbox();

                    while (client.NextEmail())
                    {
                        Console.WriteLine("Original Body: " + client.Body);

                        string htmlless = stripHTML(client.Body);

                        Console.WriteLine("HTMLless Body: " + client.Body);

                        ArrayList numbers = client.HarvestPhoneNumbers("call 2");

                        /*if (numbers.Count > 0)
                        {
                            Console.WriteLine("Phone Numbers Harvested: ");
                            for (int i = 0; i < numbers.Count; i++)
                            {
                                Console.WriteLine("\tNo. " + i.ToString() + ": " + numbers[i]);
                            }
                        }*/
                    }

                    Console.WriteLine("testing email carrier: [email protected][email protected]=whatever.wav");
                    string test = "[email protected][email protected]=whatever.wav";

                    while (test.Length > 0)
                    {
                        string attach = test.Substring(test.LastIndexOf("=") + 1);
                        test = test.Remove(test.LastIndexOf("="));
                        Console.WriteLine("attach: " + attach);
                        string to = test.Substring(test.LastIndexOf("~") + 1);
                        test = test.Remove(test.LastIndexOf("~"));
                        Console.WriteLine("send above to: " + to);
                    }

                    client.CloseConnection();
                }
                catch (Pop3LoginException ex)
                {
                    Console.WriteLine("Error logging in");
                }

                emailme();
            }
 public void WaitForMail()
 {
     var pop3Client = new Pop3Client();
     pop3Client.Connect(_server, _userAddress, _password);
     while ((pop3Client.List() as List<Pop3Message>).Count == 0)
     {
         pop3Client.Disconnect();
         Thread.Sleep(5);
         pop3Client.Connect(_server, _userAddress, _password);
     }
     Pop3Message message = pop3Client.List().First();
     pop3Client.Retrieve(message);
     ProcessMessage(new OrderMessage { From = message.From });
     pop3Client.Disconnect();
 }
Example #5
0
 private void ActivatedBox_CheckedChanged(object sender, EventArgs e)
 {
     if (!activated)
     {
         Settings1 settings = new Settings1();
         settings.Reload();
         emailChecker.Interval = settings.interval;
         emailChecker.Enabled = true;
         activated = true;
         pop3client = new Pop3Client(settings.username, settings.password, settings.pop3);
         OptionsButton.Enabled = false;
     }
     else
     {
         //deactivate
         emailChecker.Enabled = false;
         OptionsButton.Enabled = true;
     }
 }
Example #6
0
        /// <summary>
        /// Gets POP3 email.
        /// </summary>
        /// <returns></returns>
        private static List<OEmailLog> GetPOP3Mail()
        {
            OApplicationSetting applicationSetting = OApplicationSetting.Current;

            Pop3Client email = new Pop3Client(applicationSetting.EmailUserName,
                Security.Decrypt(applicationSetting.EmailPassword), applicationSetting.EmailServer, applicationSetting.EmailPort);

            List<OEmailLog> emailList = new List<OEmailLog>();

            email.OpenInbox();

            while (email.NextEmail())
            {
                emailList.Add(OEmailLog.WriteToEmailLog(email.From, email.Subject, email.Body));
                email.DeleteEmail();
            }
            email.CloseConnection();
            return emailList;
        }
Example #7
0
        static void Main( string[] args )
        {
            string server = "XXXX";
            string userName = "******";
            string password = "******";

            Pop3Client pop3Client = new Pop3Client( );

            Console.WriteLine( "Connecting to POP3 server '{0}'...{1}", server, Environment.NewLine );

            pop3Client.Connect( server, userName, password, true );

            Console.WriteLine( "List Messages...{0}", Environment.NewLine );
            List<Pop3Message> messages = pop3Client.List( );

            Console.WriteLine( "Retrieve Messages...{0}", Environment.NewLine );
            foreach ( Pop3Message message in messages )
            {
                Console.WriteLine( "- Number: {0}", message.Number );

                //popClient.RetrieveHeader( message );
                //Console.WriteLine( "\t* Header: {0}", message.Header );

                pop3Client.Retrieve( message );

                Console.WriteLine( "\t* MessageID: {0}", message.MessageId );
                Console.WriteLine( "\t* Date: {0}", message.Date );
                Console.WriteLine( "\t* From: {0}", message.From );
                Console.WriteLine( "\t* To: {0}", message.To );
                Console.WriteLine( "\t* Subject: {0}", message.Subject );

                Console.WriteLine( );
            }

            Console.WriteLine( "Disconnecting...{0}", Environment.NewLine );
            pop3Client.Disconnect( );

            Console.ReadLine( );
        }
 public List<Pop3Message> GetMailMessages(string mailBoxToRead, string password)
 {
     var pop3Client = new Pop3Client();
     pop3Client.Connect(_server, mailBoxToRead, password);
     try
     {
         var polls = 0;
         while ((pop3Client.List() as List<Pop3Message>).Count == 0 && polls < 100)
         {
             pop3Client.Disconnect();
             Thread.Sleep(5);
             pop3Client.Connect(_server, mailBoxToRead, password);
             polls++;
         }
         var pop3Messages = pop3Client.List() as List<Pop3Message>;
         return pop3Messages;
     }
     finally
     {
         pop3Client.Disconnect();
     }
 }
Example #9
0
        public static void Worker(string[] args)
        {
            //#if PUBLIC_BUILD
            if (!Globals.IsValid())
                return;
            //#endif

            if (args[0] == "activatemail" && args.Length != 4)
            {
                ConsoleLog.WriteLine("activatemail pop_server login password");
                return;
            }
            if (args[0] == "activatelist" && args.Length != 2)
            {
                ConsoleLog.WriteLine("activatelist mailboxes_file");
                return;
            }

            NickNameAndPasswordGenerator gen = new NickNameAndPasswordGenerator("", 0);
            List<string> mailBoxes = null;
            if (args[0] == "activatemail")
            {
                mailBoxes = new List<string>();
                mailBoxes.Add(args[1] + ';' + args[2] + ';' + args[3] + ";xxx");
            }
            if (args[0] == "activatelist")
            {
                mailBoxes = gen.GetMailListBoxs(args[1]);
            }

            foreach (var mailbox in mailBoxes)
            {
                mailclient = new Pop3.Pop3Client();
                messagesToDelete = new List<Pop3Message>();
                messNumber = 0;
                messCount = 0;
                ConsoleLog.WriteLine("Connecting to " + mailbox.Split(';')[0]);
                mailclient.Connect(mailbox.Split(';')[0], mailbox.Split(';')[1], mailbox.Split(';')[2]);
                ConsoleLog.WriteLine("Logged in. Retrieving message list...");
                List<Pop3Message> messages = mailclient.List();
                mailclient.Retrieve(messages);

                int poolsize = Globals.threadCount;
                if ((args[0] == "activatelist") || (Globals.BotConfig.useTOR))
                    poolsize = 1;

                try
                {
                    messCount = messages.Count;
                    NerZul.Core.Utils.Bicycles.ThreadPool.ExecInPool(ActivateProc, messages, poolsize, true, Globals.ShowDlg);

                    if (args[0] == "activatelist")
                    {
                        gen.FixBoxAct(mailbox.Split(';')[3]);
                    }
                }
                catch (System.Exception e)
                {
                    ConsoleLog.WriteLine("Activate mail error: " + e.Message);
                }

                ConsoleLog.WriteLine("Deleteing processed messages...");
                mailclient.Delete(messagesToDelete);
                ConsoleLog.WriteLine("Disconnecting...");
                mailclient.Disconnect();
                ConsoleLog.WriteLine("Finished");

                messagesToDelete.Clear();
            }
        }
 public MailServer(string server, string password)
 {
     _server = server;
     _password = password;
     _pop3Client = new Pop3Client();
 }