private string getHTML(GridView gv) { this.Gridorderconfirmation.AllowPaging = false; this.Gridorderconfirmation.AllowSorting = false; this.Gridorderconfirmation.EditIndex = -1; this.GetselectedProductDetails(); Gridorderconfirmation.Columns.RemoveAt(7); Gridorderconfirmation.DataBind(); StringBuilder sb = new StringBuilder(); StringWriter textwriter = new StringWriter(sb); HtmlTextWriter htmlwriter = new HtmlTextWriter(textwriter); Gridorderconfirmation.RenderControl(htmlwriter); htmlwriter.Flush(); textwriter.Flush(); htmlwriter.Dispose(); textwriter.Dispose(); return sb.ToString(); }
protected void Payimgbtn_Click(object sender, ImageClickEventArgs e) { try { string emailGR = getHTML(Gridorderconfirmation); MailMessage Msg = new MailMessage(); lblcomfirmationmail.Text = Session["Useremail"].ToString(); lblmailtotalcost.Text = Session["cost"].ToString(); lblusername.Text = Session["username"].ToString(); Msg.From = new MailAddress(lblcomfirmationmail.Text); Msg.To.Add(lblcomfirmationmail.Text); Msg.Subject = "Your Order Details"; Msg.Body = "Dear "+lblusername.Text +"" + emailGR + " " + "Total Amout:" + " " + lblmailtotalcost.Text + "<br/>"; Msg.IsBodyHtml = true; Msg.BodyEncoding = Encoding.UTF8; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.Credentials = new System.Net.NetworkCredential("", ""); smtp.EnableSsl = true; smtp.Send(Msg); } catch { string Msg = "<script>alert('Mail Sending Failed..try again!');</script>"; ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alert", Msg, false); //Response.Write(@"<script language="'javascript'">alert('Mail Sending Failed..try again!')</script>"); } this.Gridorderconfirmation.AllowPaging = true; this.Gridorderconfirmation.AllowSorting = true; this.Gridorderconfirmation.EditIndex = -1; this.GetselectedProductDetails(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)