kindly fix this issue..
im trying to send email to selected users frm gridview using checkbox
im getting error in
string email =row.Cells[2].Text;
s.To.Add(email);
It cant the read the selected values in gridview...
source file-------------------
<%@ Page Language="C#" Debug="true" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
subject | |
| message |
aspx.cs file.........................................
protected void btnsubmit_Click(object sender, EventArgs e)
{
string id = string.Empty;
MailMessage s = new MailMessage();
s.From = new MailAddress("[email protected]");
s.Subject = txtsubject.Text;
s.Body = txtmessage.Text;
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox chk = (CheckBox)row.FindControl("CheckBox1");
{
if (chk.Checked==true)
{
string email =row.Cells[2].Text;
s.To.Add(email);
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
NetworkCredential p = new NetworkCredential();
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "********");
smtp.EnableSsl = true;
smtp.Send(s);
}
}
}
}

Brijendra GautamRank #1,900 · 778 reputationPosted Mar 18, 2014, 1:15 AM EDT
Label lblEmail = (Label) row.FindControl("lbl3");
string email = lblEmail.Text;