0

below is my code, I am stuck that how to send all information using HTML table, also m saving my post to DB, this whole working fine but I really stuck in formatting the output in HTML, please help, m working on it after long long time.

    [HttpPost]
    public ActionResult RegUser(UserDtl userModel, string CompanyName, string Email, string CRN, string EmpStrength, string Mobile, string Address)
    {
        try
        {
            using (DbModels dbModel = new DbModels())
            {
                dbModel.UserDtls.Add(userModel);
                dbModel.SaveChanges();
            }


                if (ModelState.IsValid)
                {
                    var senderemail = new MailAddress("shakil.7878@gmail.com", "deem-admin");
                    var receiveremail = new MailAddress(Email, "New Request");

                    var password = "inDia123#";
                    var sub = CompanyName;
                    var body = "<table> <td><tr>{CompanyName}</tr><td> <td><tr>{Email}</tr><td> </table>";

                    var smtp = new SmtpClient
                    {
                        Host = "smtp.gmail.com",
                        Port = 587,
                        EnableSsl = true,
                        DeliveryMethod = SmtpDeliveryMethod.Network,
                        UseDefaultCredentials = false,
                        Credentials = new NetworkCredential(senderemail.Address, password)
                    };

                    using (var mess = new MailMessage(senderemail, receiveremail)
                    {
                        Subject = sub,
                        Body = body
                    }
                    )
                    {
                        smtp.Send(mess);
                    }

                    ModelState.Clear();
                    ViewBag.SuccessMessage = "Request sent Successful. We will send you Registration Details on your email address.";
                    return View();



                }



            //ModelState.Clear();
            //ViewBag.SuccessMessage = "Request sent Successful. We will send you Registration Details on your email address.";

        }
        catch (Exception ex)
        {


        }
        return View("RegUser", new UserDtl());

    }
Ashiquzzaman
  • 5,129
  • 3
  • 27
  • 38
shakil
  • 51
  • 5

0 Answers0