private void btnComposeMail_Click(object sender, System.EventArgs e)
        {
            if (smtp1.Active || pop31.Active)
            {
                return;
            }

            MessageFrm dlg = new MessageFrm();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                try {
                    mailMessage1.BuildMessage(dlg.memBody.Text, "");
                    mailMessage1.From.FullAddress      = dlg.edtFrom.Text;
                    mailMessage1.ToList.EmailAddresses = dlg.edtTo.Text;
                    mailMessage1.Subject = dlg.edtSubject.Text;

                    smtp1.Server   = edtSmtpServer.Text;
                    smtp1.UserName = edtUser.Text;
                    smtp1.Password = edtPassword.Text;

                    smtp1.Open();
                    smtp1.Send(mailMessage1);
                    smtp1.Close();

                    MessageBox.Show("The message was sent successfully");
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                    smtp1.Close();
                }
            }
        }
        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();
            }
        }