Esempio n. 1
0
 private void btnLogout_Click(object sender, EventArgs e)
 {
     frmLogin login = new frmLogin();
     login.Show();
     this.Close();
 }
Esempio n. 2
0
        private void btnMail_Click(object sender, EventArgs e)
        {
            if (txtEmail.Text == "")
            {
                MessageBox.Show("Enter your email", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEmail.Focus();
                return;
            }
            try
            {

                Cursor = Cursors.WaitCursor;
                timer1.Enabled = true;

                String query = "SELECT Password,UserName FROM users_tb Where Email = '" + txtEmail.Text + "'";
                reader = db.selectQuery(query);
                if (reader.Read())
                {
                    MailMessage Msg = new MailMessage();
                    // Sender e-mail address.
                    Msg.From = new MailAddress("*****@*****.**");
                    // Recipient e-mail address.
                    Msg.To.Add(txtEmail.Text);
                    Msg.Subject = "Your Password Details";
                    Msg.Body = "User Name:    " + Convert.ToString(reader["UserName"]) + "  ||  " + " Your Password:"******"Password"]) + "";
                    Msg.IsBodyHtml = true;
                    // your remote SMTP server IP.
                    SmtpClient smtp = new SmtpClient();
                    smtp.Host = "smtp.gmail.com";
                    smtp.Port = 587;
                    smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "imran6768");
                    smtp.EnableSsl = true;
                    smtp.Send(Msg);
                    MessageBox.Show("Password Successfully sent " + ("\r\n" + "Please check your mail"), "Mail Sent", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide();
                    frmLogin frm = new frmLogin();
                    frm.Show();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Your Email Address is Invalid!!" + Environment.NewLine + "Please Enter Valid Email Address", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtName.Clear();
                    txtName.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }