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();
        }
Exemplo n.º 2
0
        private void btnReceive_Click(object sender, System.EventArgs e)
        {
            if (smtp1.Active || pop31.Active)
            {
                MessageBox.Show("Message sending / retrieving is in progress");
                return;
            }

            progressBar1.Value = 0;
            lblProgress.Text   = "%";

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

            try {
                pop31.Open();

                if (pop31.MessageCount == 0)
                {
                    MessageBox.Show("There are no messages in the mailbox");
                    pop31.Close();
                    return;
                }

                pop31.Retrieve(1, mailMessage1);                 //retrieve first mail message

                edtFrom.Text  = mailMessage1.From.FullAddress;
                edtTo.Text    = mailMessage1.ToList.EmailAddresses;
                memBody.Lines = mailMessage1.MessageText;

                pop31.Close();

                lblProgress.Text = "100 %";
                MessageBox.Show(String.Format("The first message was received. Total messages: {0}", pop31.MessageCount));
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                pop31.Close();
            }
        }
        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();
            }
        }
Exemplo n.º 4
0
 private void btnDisconnect_Click(object sender, System.EventArgs e)
 {
     lvMessages.Items.Clear();
     ClearMessage();
     pop31.Close();
 }