Code Behind part to setup a Enquiry form in a ASP.Net Website

By | 09/01/2013

To Setup a Enquiry form in a ASP.Net Website

Add this Namespaces in your Codebehind file:

using System.Net.Mail;
using System.Net;

The System.Net.Mail namespace contains classes that enable you to construct and send messages using the CDOSYS (Collaboration Data Objects for Windows 2000) message component. The mail message is delivered either through the SMTP mail service built into Microsoft Windows 2000 or through an arbitrary SMTP server.

Code Behind Part:

public partial class Login : System.Web.UI.Page

protected void Button1_Click1(object sender, EventArgs e)

MailMessage msg = new MailMessage();

msg.To.Add(new MailAddress("Your Mail Address"));

msg.From = new MailAddress(TextBox2.Text);

msg.Subject = TextBox4 .Text ;

msg.Body = TextBox1.Text +Environment.NewLine + TextBox3.Text + Environment.NewLine + TextBox2.Text + Environment.NewLine + TextBox4.Text;

SmtpClient client = new SmtpClient();

client.Host = "";

client.Port = 587;

NetworkCredential cred = new NetworkCredential("Your Mail Address", "Your Mail Password");

client.Credentials = cred;

client.EnableSsl = true;



Post By Praveen (38 Posts)

Website: →


About Praveen

Praveen S has written 38 post in this blog.

Leave a Reply