I'm using MVC 4 on both local and production. From my Index.cshtml file I have a simple link:
@Html.ActionLink("Click to send an email", "Email", "Home");
where Email is defined in my HomeController as:
public ActionResult Email()
{
// send mail
MailMessage message = new MailMessage();
message.From = new MailAddress("email@email.com");
message.To.Add(new MailAddress("tony@email.com"));
message.Subject = "User submitted a message...";
string msgBody = "<html><body>"
+ "You have a new user submitted form request sent at "
+ DateTime.Now + ":
message.Body = msgBody;
SmtpClient client = new SmtpClient();
client.Send(message);
return RedirectToAction("Index");
}
I have removed the client's email address and other details, but that's the basic gist of things. There is no "Email" view in particular, it just sends an email using system.net and returns home.
This works smoothly in Visual Web Express locally, on Arvixe hosting it generates a "Resource cannot be found" exception.