private void sendReceive_btn_Click(object sender, EventArgs e) { dbHandler = new DBHandler(); List <Message> mails = new List <Message>(); mails = POPClient.GetAllMails(Setting.Default.pop3_server, Setting.Default.pop3_port, Setting.Default.ssl, Setting.Default.username, Setting.Default.password); foreach (Message mail in mails) { dbHandler.InsertMail(mail); } }
public MailClient() { this.Load += MailClient_Load; InitializeComponent(); pop3 = new POPClient(); smtp = new SMTPClient(); dbHandler = new DBHandler(); POP3Worker = new BackgroundWorker(); POP3Worker.WorkerReportsProgress = true; POP3Worker.DoWork += new DoWorkEventHandler(pop3.GetAllMails); POP3Worker.ProgressChanged += new ProgressChangedEventHandler(WorkerProgressChanged); POP3Worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(WorkerRunCompleted); SMTPWorker = new BackgroundWorker(); SMTPWorker.DoWork += new DoWorkEventHandler(smtp.Send); SMTPWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(sendWorkerRunCompleted); }