示例#1
0
        private void _bFilterEmails_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.Connect(_tbPop3Server.Text, _tbUserName.Text, _tbPassword.Text);

                AddressCollection ac;
                HeaderCollection hc = new HeaderCollection();

                //Retrive a message headers
                for (int n = 1; n < pop.MessageCount + 1; n++)
                {
                    Header h = pop.RetrieveHeaderObject(n);
                    ac = new AddressCollection();
                    ac.Add(h.From);
                    ac = Validator.Filter(ac);

                    //If address is not filtered
                    if (ac.Count > 0)
                    {
                        hc.Add(h);
                    }
                }

                this.AddLogEntry(string.Format(" {0} messages passed the filter", hc.Count.ToString()));
            }

            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();
                }
            }
        }
示例#2
0
        private void retrieveMessagesButton_Click(object sender, EventArgs e)
        {
            ActiveUp.Net.Mail.Pop3Client client = new ActiveUp.Net.Mail.Pop3Client();
            client.Connect(this.pop3ServerHostTextbox.Text, Convert.ToInt32(this.pop3ServerPortNumericUpDown.Value),
                this.pop3ServerUsernameTextbox.Text, this.pop3ServerPasswordTextbox.Text);
            
            HeaderCollection headers = new HeaderCollection();
            for(int index = 1; index <= client.MessageCount; index++)
                headers.Add(client.RetrieveHeaderObject(index));

            client.Close();

            this.dataGridView1.DataSource = headers;
        }