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();
            }
        }
        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;
        }
Example #3
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 #4
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();
            }