bonjour,
je souhaite envoyer un email à la personne sélectionné dans la gridview ,
j'ai arrivé à ce code mais ça ne marche pas , la colonne 4 représente EMAIL alors str.tostring() n'est pas reconnu , normalement la valeur doit être string ! voici le code merci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  protected void Button1_Click(object sender, EventArgs e)
    {
 
   // StringBuilder object
         StringBuilder str = new StringBuilder();
   // Select the checkboxes from the GridView control
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            GridViewRow row = GridView1.Rows[i];
            bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked;
 
            if (isChecked)
                            {
                // Column 1 is the name column
                str.Append(GridView1.Rows[i].Cells[4].Text);
 
                            }
         }
 
        MailMessage email = new MailMessage("admi.diff@gmail.com", str.ToString(), "demande", "votre demande à été bien traité ;)");
        email.IsBodyHtml = false;
        NetworkCredential mailAuthentication = new NetworkCredential("admi.diff@gmail.com", "******");
        SmtpClient smtpserver = new SmtpClient("smtp.gmail.com", 587);
        smtpserver.EnableSsl = true;
        smtpserver.UseDefaultCredentials = false;
        smtpserver.Credentials = mailAuthentication;
        smtpserver.Send(email);
 
        // prints out the result
        Response.Write(str.ToString());
 
    }
}