Mailto on submit button

Pavel Shchegolevatykh picture Pavel Shchegolevatykh · Sep 27, 2012 · Viewed 157.8k times · Source

Is it possible to implement mailto: function on submit button like <input type="submit" />? I use ASP.NET MVC. Maybe there is some tricky controller action result to achieve this. Could you please help me?

P.S. I know that I can make anchor looks like a button.

Answer

zzzzBov picture zzzzBov · Sep 27, 2012

In HTML you can specify a mailto: address in the <form> element's [action] attribute.

<form action="mailto:[email protected]" method="GET">
    <input name="subject" type="text" />
    <textarea name="body"></textarea>
    <input type="submit" value="Send" />
</form>

What this will do is allow the user's email client to create an email prepopulated with the fields in the <form>.

What this will not do is send an email.