예제 #1
0
        private void metroButton1_Click_1(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtMail.Text) || string.IsNullOrEmpty(txtPass.Text))
            {
                MessageBox.Show("Neither E-mail address nor Password can be empty!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            else if (!DataService.IsValidMail(txtMail.Text))
            {
                MessageBox.Show("Please, type valid E-mail address!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                if (rememberChk.Checked)
                {
                    DataService.SerializeUserData(txtMail.Text, txtPass.Text);
                }
                {
                    MailboxService service = new MailboxService("imap.gmail.com", new UserData(txtMail.Text, txtPass.Text));

                    if (service.IsAuthenticated())
                    {
                        MessageBox.Show("You won :)");
                        new MainForm(service).Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Authentication error! Please, check E-mail and Password again!", "Authentication error!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }
예제 #2
0
 public MainForm(MailboxService myService)
 {
     InitializeComponent();
     this.mailService = myService;
 }