Exemplo n.º 1
0
//INSTANT C# WARNING: Strict 'Handles' conversion only applies to 'WithEvents' fields declared in the same class - the event will be wired in 'SubscribeToEvents':
//ORIGINAL LINE: Protected Sub GridView1_SelectedIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSelectEventArgs) Handles GridView1.SelectedIndexChanging
    protected void GridView1_SelectedIndexChanging(object sender, System.Web.UI.WebControls.GridViewSelectEventArgs e)
    {
        string id   = GridView1.DataKeys[e.NewSelectedIndex].Values[0].ToString();
        string Pass = "";

        DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider();
        Pass = data.ForgotPassword(id);

        Pass = System.Text.Encoding.Default.GetString(Convert.FromBase64String(Pass));

        try
        {
            using (System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(ConfigurationManager.AppSettings["AdminEmail"], GridView1.Rows[e.NewSelectedIndex].Cells[2].Text, "Your password for the Guestbook", "Your password is: " + Pass))
            {
                System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(ConfigurationManager.AppSettings["MailServer"]);
                smtp.Send(mail);
            }
        }
        catch (Exception ex)
        {
            DisplayError(ex.Message);
        }
    }