I would (as the question states) like to make an asynchronous call, preferably using ASP.net AJAX.
The code for the WebMethod looks like this:
[WebMethod] public void SendMail(string name, string email, string subject, string body) { MailMessage toSend = new MailMessage(email, address@domain.com, subject, body); var smtp = new SmtpClient(); smtp.Send(toSend); }
The fields on the view are, not surprisingly: name, email, subject, body.
In my attempts to do this I haven’t been able to get to the WebMethod. The service reference is in place, so at least I didn’t screw that up.
Thanks for the help…
Here you can find an example of invoking asynchronous methods with AJAX in ASP.NET MVC with elements like
You can receive the params in the controller method and call the webservice from there.