I'm trying to receive an email once my form is submitted on my webpage. At the moment it submits fine without any errors but I don't receive the email. Does anyone know what code I have to add in the code behind page to make this work?
Here is the html;
<h2>Contact Us</h2>
<br />
<table>
<tr>
<td style="align-items:center">
Name:</td>
<td>
<asp:TextBox ID="txtName"
runat="server"
Columns="40"></asp:TextBox>
</td>
</tr>
<tr>
<td style="align-items:center">
email:</td>
<td>
<asp:TextBox ID="txtEmail"
runat="server"
Columns="40"></asp:TextBox>
</td>
</tr>
<!-- Message -->
<tr>
<td style="align-items:center">
What are you looking for?
</td>
<td>
<asp:TextBox ID="txtMessage"
runat="server"
Columns="40"
Rows="6"
TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td style="align-items:center">
What would you be willing to pay for this app?</td>
<td>
<asp:TextBox ID="txtPay"
runat="server"
Columns="40"></asp:TextBox>
</td>
</tr>
<!-- Submit -->
<tr style="align-items:center">
<td colspan="2">
<asp:Button ID="btnSubmit" runat="server" Text="Submit"
onclick="btnSubmit_Click" /><br />
</td>
</tr>
<!-- Results -->
<tr style="align-items:center">
<td colspan="2">
<asp:Label ID="lblResult" runat="server"></asp:Label>
</td>
</tr>
</table>
this is the code behind;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Telluswhatyouwant : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
//Create the msg object to be sent
MailMessage msg = new MailMessage();
//Add your email address to the recipients
msg.To.Add("ronan.byrne@mhlabs.net");
//Send the msg
client.Send(msg);