Search code examples
htmlasp.net-mvcmailto

Mailto on submit button


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.


Solution

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

    <form action="mailto:youraddr@domain.tld" 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.