예제 #1
0
        private void Button_Click(object sender, RoutedEventArgs ex)
        {
            using (client = new ImapClient())
            {
                bool error = false;
                try
                {
                    client.ServerCertificateValidationCallback = (s, c, h, e) => true;

                    client.Connect("imap.yandex.ru", 993, true);
                    login    = LoginTextBox.Text;
                    password = PasswordTextBox.Password;
                    client.Authenticate(login, password);
                }
                catch (Exception)
                {
                    error = true;
                    MessageBox.Show("Login Error");
                }
                if (!error)
                {
                    DataEnterWindowYandex form = new DataEnterWindowYandex();

                    client.Disconnect(true);
                    form.Show();
                    this.Hide();
                }
            }
        }
예제 #2
0
        // public ImapClient Client { get => Client; set => Client = value; }

        public void Autorize(string login, string password, string clientImap, Window loginForm)
        {
            Window form;

            using (client = new ImapClient())
            {
                bool error = false;
                try
                {
                    client.ServerCertificateValidationCallback = (s, c, h, e) => true;

                    client.Connect(clientImap, 993, true);
                    //login = LoginTextBox.Text;
                    //password = PasswordTextBox.Password;
                    client.Authenticate(login, password);
                }
                catch (Exception)
                {
                    error = true;
                    MessageBox.Show("Login Error");
                }
                if (!error)
                {
                    if (loginForm.ToString() == "Email_Helper.GmailLoginWindow")
                    {
                        form = new DataEnterWindowGmail();
                    }
                    else if (loginForm.ToString() == "Email_Helper.MailruLoginWindow")
                    {
                        form = new DataEnterWindow();
                    }
                    else
                    if (loginForm.ToString() == "Email_Helper.YahooLoginWindow")
                    {
                        form = new DataEnterWindowYahoo();
                    }
                    else if (loginForm.ToString() == "Email_Helper.YandexLoginWindow")
                    {
                        form = new DataEnterWindowYandex();
                    }
                    else
                    {
                        form = new Window(); MessageBox.Show("Unknown Form");
                    }


                    client.Disconnect(true);
                    form.Show();
                    loginForm.Hide();
                }
            }
        }