Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 787
Pavel Shchegolevatykh Avatar asked Sep 27 '12 17:09

Pavel Shchegolevatykh


People also ask

How do I add a mailto to a button?

If you're not using a rich text module or a CTA, you can create a mailto link manually instead. Highlight the text you want to link, then click the Link to dropdown menu and select URL. In the Link URL field, enter mailto:[email protected], then replace [email protected] with the recipient's email address.

How do I code my submit button go to an email address?

You might use Form tag with action attribute to submit the mailto . Show activity on this post. But if you are doing it from a button you may want to look into a javascript solution.

How do I use mailto in forms?

Mailto link is a default way to sending a mail when the consumer wants to communicate or wants to give feedback, then clicking the mailto link will open a default sending mail window. So we can use mailto which directs us to the mail once the form is submitted.

How do I link a submit button to a link?

To link a submit button to another webpage using HTML Form Tags: Using the HTML Form's Action Attribute, we can link the submit button to a separate page in the HTML Form element. Here, declare/write the “Submit button” within HTML Form Tags and give the File Path inside the HTML form's action property.


2 Answers

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.

like image 77
zzzzBov Avatar answered Sep 28 '22 05:09

zzzzBov


This seems to work fine:

<button onclick="location.href='mailto:[email protected]';">send mail</button> 
like image 45
Greald Henstra Avatar answered Sep 28 '22 05:09

Greald Henstra