-1

Please any one help me out to design enquiry form that having Name,Mobile No,Query and Address attributes and all these attributes should be sended to my email when visitor clicked send button after fill same details. Need code for MVC..

  • 1
    You could start by looking at this thread https://stackoverflow.com/questions/23502407/mvc-contact-form-with-email – lofihelsinki Jan 24 '19 at 07:06
  • Possible duplicate of [MVC Contact Form with Email](https://stackoverflow.com/questions/23502407/mvc-contact-form-with-email) – Ratheesh Jan 24 '19 at 07:44

1 Answers1

0

First you need to create a model something like this:

public class Inquiry
{       
    public string Name { get; set; }
    public string Email { get; set; }
    public string PhoneNumber { get; set; }
    public DateTime Date { get; set; }
    public string Message { get; set; }
}

Then you need in your controller when returning your view to pass in a new model:

[HttpGet]
    public IActionResult Contact()
    {
        return View(new Inquiry());
    }

Then create your form in HTML

Then in your controller have:

[HttpPost]
    public IActionResult Contact(Inquiry inquiry)
{
     {new Email().Send(inquiry); //Using your email class

     return View(<Thank you page or whatever>);
}

Don't forget validations etc...

David Edel
  • 569
  • 4
  • 18