protected void Button1_Click(object sender, System.EventArgs e)
        {
            DataTable messages = new DataTable();

            messages.Columns.Add("Subject");
            messages.Columns.Add("From");
            messages.Columns.Add("Date");

            pop31.Server   = edtServer.Text;
            pop31.UserName = edtUser.Text;
            pop31.Password = edtPassword.Text;
            pop31.Open();

            for (int i = 1; i <= pop31.MessageCount; i++)
            {
                pop31.RetrieveHeader(i, mailMessage1);

                DataRow row = messages.NewRow();
                row["Subject"] = mailMessage1.Subject;
                row["From"]    = mailMessage1.From;
                row["Date"]    = mailMessage1.Date;
                messages.Rows.Add(row);
            }

            DataGrid1.DataSource = messages;
            DataGrid1.DataBind();

            pop31.Close();
        }
예제 #2
0
        private void FillMessages()
        {
            lvMessages.Items.Clear();
            ClearMessage();

            for (int i = 0; i < pop31.MessageCount; i++)
            {
                pop31.RetrieveHeader(i + 1, mailMessage1);

                ListViewItem item = lvMessages.Items.Add(mailMessage1.From.FullAddress);
                item.SubItems.Add(mailMessage1.Subject);
                item.SubItems.Add(mailMessage1.Date.ToString());
                item.SubItems.Add(pop31.GetUID(i + 1).ToString());
                item.SubItems.Add(i.ToString());
            }
        }
        private void btnCheckMail_Click(object sender, System.EventArgs e)
        {
            if (smtp1.Active || pop31.Active)
            {
                return;
            }

            pop31.Server   = edtPop3Server.Text;
            pop31.UserName = edtUser.Text;
            pop31.Password = edtPassword.Text;

            try {
                pop31.Open();

                lbMessages.Items.Clear();

                for (int i = 0; i < pop31.MessageCount; i++)
                {
                    pop31.RetrieveHeader(i + 1, mailMessage1);
                    if (mailMessage1.Subject == "")
                    {
                        lbMessages.Items.Add(mailMessage1.From);
                    }
                    else
                    {
                        lbMessages.Items.Add(mailMessage1.Subject);
                    }
                }

                pop31.Close();

                MessageBox.Show(string.Format("Collecting completed, {0} messages in the mailbox", pop31.MessageCount));
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                pop31.Close();
            }
        }