JohnDoe4136
JohnDoe4136

Reputation: 539

Sending a asp form with outlook email

I'm wondering if it is possible to create a form in asp.net c#, enter submit, it will be sent using outlook.

<label>Name: </label>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<label>Age: </label>
<asp:TextBox ID="txtAge" runat="server"></asp:TextBox>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" onclick="btnSubmit_Click" />

Upvotes: 1

Views: 323

Answers (1)

Luaan
Luaan

Reputation: 63772

That is not possible.

The Outlook is on your client's computer, while the server-side code executes on the server.

There is one option - you can use the mailto: protocol. It definitely works with <a href="mailto:[email protected]">Mail me!</a>, and it might work with a (custom) form too:

<form action="mailto:[email protected]" method="get">
 Subject: <input name="subject" /><br />
 Message: <br />
 <textarea name="body" />
</form>

But in ASP.NET WebForms, you've got one global form, so this will not work.

However, you most likely don't want to do that anyway. For one, there's no telling if your clients use an e-mail client at all. Second, it shows your own e-mail address to bots, so you're bound to get tons of spam rather soon. Third, this completely avoids any server side code you might want to e.g. record the e-mail or some such.

Upvotes: 1

Related Questions