private void btn_OK_Click(object sender, EventArgs e)
        {
            string hostname;
            int    port;
            string username;
            string password;
            bool   parseCondition = true;

            if (string.IsNullOrEmpty(txt_hostname.Text))
            {
                txt_hostname.BackColor = Color.Red;
                parseCondition         = false;
            }

            if (!int.TryParse(txt_port.Text, out port))
            {
                txt_port.BackColor = Color.Red;
                parseCondition     = false;
            }

            if (string.IsNullOrEmpty(txt_SenderMail.Text))
            {
                txt_SenderMail.BackColor = Color.Red;
                parseCondition           = false;
            }

            if (string.IsNullOrEmpty(txt_SenderPassword.Text))
            {
                txt_SenderPassword.BackColor = Color.Red;
                parseCondition = false;
            }

            hostname = txt_hostname.Text;
            username = txt_SenderMail.Text;
            password = txt_SenderPassword.Text;

            if (parseCondition)
            {
                try
                {
                    SmtpProtocol.ConnectClientAndAuthorize(hostname, port, username, password);
                    MailForm mailForm = new MailForm();
                    mailForm.Show();
                }
                catch (SmtpException ex)
                {
                    MessageBox.Show(@"Apgailestaujame, tačiau įvyko klaida: " + ex.GetMessage(), @"Klaida", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                catch (Exception)
                {
                    MessageBox.Show(@"Apgailestaujame, tačiau įvyko neatpažinta klaida ", @"Nežinoma klaida", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
        }
Beispiel #2
0
        private void btn_OK_Click(object sender, EventArgs e)
        {
            string recipient;
            string subject;
            string message;
            bool   parseCondition = true;

            if (string.IsNullOrEmpty(txt_Rcpt.Text))
            {
                txt_Rcpt.BackColor = Color.Red;
                parseCondition     = false;
            }

            if (string.IsNullOrEmpty(txt_Subject.Text))
            {
                txt_Subject.BackColor = Color.Red;
                parseCondition        = false;
            }

            if (string.IsNullOrEmpty(txt_Message.Text))
            {
                txt_Message.BackColor = Color.Red;
                parseCondition        = false;
            }

            recipient = txt_Rcpt.Text;
            subject   = txt_Subject.Text;
            message   = txt_Message.Text;

            if (parseCondition)
            {
                try
                {
                    SmtpProtocol.SendMail(recipient, subject, message);
                }
                catch (SmtpException ex)
                {
                    MessageBox.Show(@"Apgailestaujame, tačiau įvyko klaida: " + ex.GetMessage(), @"Klaida", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                catch (Exception)
                {
                    MessageBox.Show(@"Apgailestaujame, tačiau įvyko neatpažinta klaida ", @"Nežinoma klaida", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }

                MessageBox.Show(@"Jūsų laiškas išsiųstas sėkmingai", @"Pranešimas", MessageBoxButtons.OK,
                                MessageBoxIcon.Asterisk);
            }
        }
 private void btn_Cancel_Click(object sender, EventArgs e)
 {
     SmtpProtocol.Close();
     Close();
 }
Beispiel #4
0
 private void btn_Cancel_Click(object sender, EventArgs e)
 {
     // uzdare forma atjungiam ir klienta
     SmtpProtocol.Close();
     Close();
 }