MailMessage mail = new MailMessage();
mail.To = HLBLUserEmail.Text;
mail.From = "'Sender<sendere@domain.com>";
//mail.Headers.Add("Reply-To", "sender@domain.com");
mail.Subject = "Subject";
mail.BodyFormat = MailFormat.Html;
mail.Body = "<div style='position:relative; left: 50px;'><p>";
mail.Body += "" + DateTime.Now + "<br />";
mail.Body += "<br/>Dear, " + userName + "<br />";
mail.Body += "<br />Your order has been submitted.<br />";
mail.Body += "Order Number is : " + orderID + ";";
mail.Body += "<br />Following is the list of ordered items:<br /></p>";
String strConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection myConnection = new SqlConnection(strConnectionString);
string ItemNo, Description, Price, qty;
mail.Body += "<table border='1' style='font-size: 8pt;'>";
foreach (GridViewRow row in GridView1.Rows)
{
ItemNo = (row.FindControl("ItemNo") as Label).Text;
Description = (row.FindControl("Description") as Label).Text;
Price = (row.FindControl("Price") as Label).Text;
qty = (row.FindControl("SelectedQty") as Label).Text;
mail.Body += "<tr>";
mail.Body += "<td>" + ItemNo + "</td><td>" + Description + "</td><td>" + Price + "</td><td>" + qty + "</td><td>" + Convert.ToInt32(Price) * Convert.ToInt32(qty) + "</td>";
mail.Body += "</tr>";
}
mail.Body += "</table></div><br /><br /><br />";
SmtpMail.SmtpServer = "smtp.domain.com";
SmtpMail.Send(mail);
