Click here to Skip to main content
15,747,911 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello, could someone please help me, I would like to know the code for the submit button in c# so when someone presses the button it sends a email to my email address

"Code for button"? I don't think you need exactly, this, but people should get answers their questions deserve.
<form ...>
    <input type="submit" value="Submit">

Please see:[^].

If you do it this way, all data in the form (per attributes name and their values) will be automatically put to a single HTTP request and sent to the server side. This is how the Web form work. This is your responsibility to process form data on the server side.

As to e-mails, be extra careful. This is a very vulnerable points. One wrong move, and your server host will be turned into a zombie sending spam, or something like that, in no time. Injection of malicious code in form data is just a kid's play. Don't even play with the idea of sending any data as is. To avoid the exploit, please see my past answer:
unable to send mail , it showing the error in below code .[^].

Share this answer
why do you need to use submit button if there is an asp button?
try this

<asp:button id="button" runat="server" onclick="click" cssclass="contact" xmlns:asp="#unknown">
//If you don't want to use the asp:button

<button id="button" runat="server" OnServerClick="click" >

in code behind

protected void click(object sender, EventArgs e)
    //do send email
Share this answer
Share this answer
Sergey Alexandrovich Kryukov 17-Feb-14 19:45pm    
Frankly, this is a pretty bad article. In addition to its low quality, this is a direct invitation for easy exploit of the site using such a naive approach.
Please see my answer.
[no name] 17-Feb-14 19:57pm    
Frankly I don't know who you are but you are doing my head in,
Sergey Alexandrovich Kryukov 17-Feb-14 20:23pm    
Excuse me?... ",..."? what? Did you read my answer? Who is who is really irrelevant...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900