Exemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     label4.Text = null;
     label5.Text = null;
     button1.Focus();
     if (textBox1.Text.Equals("") && textBox2.Text.Equals(""))
     {
         label4.Text = "This is required";
         label5.Text = "This is required";
         //ohannah.Speak("Mail id is required");
         //ohannah.Speak("Password is required");
     }
     if (textBox1.Text.Equals(""))
     {
         label4.Text = "This is required";
         //ohannah.Speak("Mail id is required");
     }
     else
     {
     }
     if (textBox2.Text.Equals(""))
     {
         label5.Text = "This is required";
         //ohannah.Speak("Password is required");
     }
     else
     {
     }
     if (!textBox1.Text.Equals("") && !textBox2.Text.Equals(""))
     {
         if (IsValidEmail(textBox1.Text))
         {
             try
             {
                 address  = textBox1.Text.Trim();
                 password = textBox2.Text.Trim();
                 SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
                 client.EnableSsl             = true;
                 client.Timeout               = 10000;
                 client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                 client.UseDefaultCredentials = false;
                 client.Credentials           = new NetworkCredential(Email.address, Email.password);
                 //MessageBox.Show(address + password);
                 //ohannah4777 ohannah47
                 MailMessage msg = new MailMessage(address, "*****@*****.**", "Test", "Test");
                 client.Send(msg);
                 //MessageBox.Show("Logged in!");
                 address  = textBox1.Text; //.Trim();
                 password = textBox2.Text; //.Trim();
                 ohannah.Speak("Logging in");
             }
             catch (Exception ex)
             {
                 //MessageBox.Show("UserId and Password does not match.\n" + ex.Message);
                 ohannah.Speak("UserId and Password does not match.");
                 return;
             }
             this.ohannah.SpeakAsyncCancelAll();
             engine.Dispose();
             this.Dispose();
             MailBox m = new MailBox();
             m.Show();
         }
         else
         {
             //MessageBox.Show("Email format is not valid");
             ohannah.Speak("Email format is not valid");
         }
     }
 }