public static void SendEmail(decimal orderamount, int orderid, string toemail) { RamOnlineShppngDataContext db = new RamOnlineShppngDataContext(); var query = from prd in db.Orderedproducts where prd.CustomerOrderId == orderid select prd; var body = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>"; foreach (var item in query) { var product = db.Products.Single(p => p.Id == item.ProductId); body += "<p>" + product.Name + " : " + product.Price + " $</p>"; } body += "<p><a href='http://*****:*****@gmail.com"); // replace with valid value message.Subject = "Your Order Details On Ram online Shopping"; message.Body = string.Format(body, "Ram Online Shopping", "*****@*****.**", "Your order has been successfull, plese check your order details."); message.IsBodyHtml = true; using (var smtp = new SmtpClient()) { var credential = new NetworkCredential { UserName = "******", // replace with valid value Password = "******" // replace with valid value }; smtp.Credentials = credential; smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.EnableSsl = true; smtp.Send(message); //return RedirectToAction("Sent"); } }