private void lvMessages_SelectedIndexChanged(object sender, System.EventArgs e) { lock (this) { if (processing) { return; } processing = true; try { if (pop31.Active && lvMessages.SelectedItems.Count > 0) { pop31.Retrieve(Convert.ToInt32(lvMessages.SelectedItems[0].SubItems[4].Text) + 1, mailMessage1); edtFrom.Text = mailMessage1.From.FullAddress; edtSubject.Text = mailMessage1.Subject; memBody.Lines = mailMessage1.MessageText; } else { ClearMessage(); } } finally { processing = false; } } }
private void lbMessages_DoubleClick(object sender, System.EventArgs e) { if (pop31.Active || (lbMessages.SelectedIndex < 0)) { return; } pop31.Server = edtPop3Server.Text; pop31.UserName = edtUser.Text; pop31.Password = edtPassword.Text; try { pop31.Open(); pop31.Retrieve(lbMessages.SelectedIndex + 1, mailMessage1); MessageFrm dlg = new MessageFrm(); dlg.edtFrom.Text = mailMessage1.From.FullAddress; dlg.edtTo.Text = mailMessage1.ToList.EmailAddresses; dlg.edtSubject.Text = mailMessage1.Subject; dlg.memBody.Lines = mailMessage1.MessageText; dlg.edtFrom.ReadOnly = true; dlg.edtTo.ReadOnly = true; dlg.edtSubject.ReadOnly = true; dlg.memBody.ReadOnly = true; dlg.btnSend.Enabled = false; dlg.edtFrom.BackColor = SystemColors.Window; dlg.edtTo.BackColor = SystemColors.Window; dlg.edtSubject.BackColor = SystemColors.Window; dlg.memBody.BackColor = SystemColors.Window; dlg.ShowDialog(); pop31.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); pop31.Close(); } }
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(); } }