Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Sep 30, 2008 09:50 AM by suhanto
Sep 29, 2008 03:32 PM|LINK
** I kno this is a little cheeky, but if you feel a little donation via paypal may help on successfull completion im more than happy to do so!!****
Hi all after eventually mastering, well when i say mastering I really mean getting the answers from these forums on how to from to email in standard asp.net.
I have decided to update my asp.net website to asp.net mvc. I have the following contact form:
<% } %>
The "email" and "enquiry" fields are required and I would like them to fire validation,, similar to the standard Login control validates in the mvc sample that is included
on start of new mvc web application.
The form is to be enabled by the HomeController.cs and the controller name is Contact same as the view name, so the controller should only fire when in Post
// Non-POST requests should just display the ChangePassword form
I have the following standard code for the controller in the HomeController.cs file:
Could someone please provide me with the necessary expertise to enable the control.
PS. Do i need to make any alterations to the web.config file also?
I am using mvc preview 5 if that makes any difference.
I have attempted to play around with existing asp.net smtp email code to try and get it to work but to no success.
So if someone could please provide me with the code to for the controller i need to get this working I would be ever so grateful.
Thank you in advance.
MVC Preview 5
Sep 30, 2008 09:50 AM|LINK
I tried the following code, and found out the MVC mechanism worked. However, because my machine is Vista, and by default Vista does not install SMTP service, I don't know if email sending works. You can try it in XP with SMTP service enabled, it should work.
public ActionResult Index()
public ActionResult Index(string name, string email, string messenger, string phone, string enquiry)
var mailMessage = new System.Net.Mail.MailMessage("email@example.com", email, "Subject: test", enquiry);
var smtp = new System.Net.Mail.SmtpClient("localhost", 25);
* The GET verb will display the contact form
* The submit button click will commence POST verb to the same controller.
* upon completion of email sending, it will display the Success view