asp.net - send entire details through email -


i want send student details company mail id .here have used grid view in grid view display student details along check box. when click particular row in grid view, details send through smtp

protected void button1_click(object sender, eventargs e)     {         using (sqlconnection con = new sqlconnection(configurationmanager.connectionstrings["connectionstring"].connectionstring))         {             sqlcommand cmd = new sqlcommand("select email details", con);             con.open();             sqldatareader rdr = cmd.executereader();             while (rdr.read())             {                  string email = rdr["email"].tostring();                  sendemail(email);             }         }     }     private void sendemail(string toemail)     {              string stremail=string.empty;         mailmessage mailmessage = new mailmessage("raj@gmail.com", toemail);         stringbuilder sbemailbody = new stringbuilder();         try         {             foreach (gridviewrow rw in gridview1.rows)             {                 checkbox chkbx = (checkbox)rw.findcontrol("chk1");                 if (chkbx != null && chkbx.checked)                 {                     stremail = ((label)rw.findcontrol("student name")).text;                 }                 sbemailbody.append(stremail);                     sbemailbody.append("");                     sbemailbody.append("hello");                     sbemailbody.append("<br/><br/>");                     sbemailbody.append("<b>testing mail</b>");                     mailmessage.isbodyhtml = true;                      mailmessage.body = sbemailbody.tostring();                     mailmessage.subject = "testing";                     smtpclient smtpclient = new smtpclient("smtp.gmail.com", 587);                      smtpclient.credentials = new system.net.networkcredential()                     {                         username = "raj@gmail.com",                         password = "1234"                     };                      smtpclient.enablessl = true;                     smtpclient.send(mailmessage);                 }             }      catch         {          }         }           }  } 

here not able send details of student grid view

because you're using ssl, try change port of smtpclient 465.

google smtp configurations


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -