Exemplo n.º 1
0
        private void backgroundWorkerDelete_DoWork(object sender, DoWorkEventArgs e)
        {
            // download email data and fill into database
            Pop3 mailbox = new Pop3(Session.Pop3Server, Session.Pop3Port);
            mailbox.Connect(Session.AccountName, Session.AccountPass);

            foreach (DataGridViewRow row in dataGridViewBoxContent.SelectedRows)
            {
                string uidl = row.Cells[0].Value.ToString();
                if (mailbox.DeleteMail(uidl) == true)
                {
                    // remove the record from database
                    string deleteStr = string.Format("DELETE FROM [Mail] WHERE [UIDL] = '{0}'", uidl);
                    if (DBAccess.ExecuteSQL(deleteStr) == false)
                    {
                        MessageBox.Show("删除邮件失败!", "邮件系统");
                    }
                }
            }

            mailbox.DisConnect();
        }
Exemplo n.º 2
0
 private void DownloadEmailData(BackgroundWorker worker)
 {
     if (Session.SettingIsValid() == false)
         return;
     // download email data and fill into database
     Pop3 mailbox = new Pop3(Session.Pop3Server, Session.Pop3Port);
     worker.ReportProgress(1, "连接到邮件服务器...");
     mailbox.Connect(Session.AccountName, Session.AccountPass);
     worker.ReportProgress(50, "接收邮件...");
     mailbox.RetrieveEmail(datatableIncome);
     LoadAllIncomeDB();
     mailbox.DisConnect();
     worker.ReportProgress(99, "从邮件服务器断开");
 }