sending email through application(contact/feedback form eg.)

Posted by Ankitsrist under ASP.NET category on | Points: 40 | Views : 4434
hey frnds,
here i will explain how to make contact form as we generaly see on various is very simple, copy paste below .aspx code

<%@ Page Language="C#" MasterPageFile="~/nationalmaster.master" AutoEventWireup="true" CodeFile="complaint form.aspx.cs" Inherits="complaint_form" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
<br />
email &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<asp:TextBox ID="TextBox2"
<br />
<br />
subject &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox><br />
<br />
body &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
<asp:TextBox ID="TextBox4" runat="server" Height="100px" Width="205px"></asp:TextBox><br />
<br />
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />

below is code separation page aspx.cs page

using System.Net.Mail;
using System.Data.SqlClient;

public partial class complaint_form : System.Web.UI.Page
dbClass db = new dbClass();
protected void Page_Load(object sender, EventArgs e)

protected void Button1_Click(object sender, EventArgs e)
MailMessage msg = new MailMessage();
msg.From = new MailAddress("");
msg.Subject = TextBox3.Text;
msg.Body = "sender name:" + TextBox1.Text + "<break>sender email:" + TextBox2.Text + "<break>sender subject:" + TextBox3.Text + "<break>sender body:" + TextBox4;
SmtpClient smtp=new SmtpClient();
smtp.Host ="";
smtp.Credentials =new System.Net .NetworkCredential("", "ur password");
smtp.EnableSsl =true ;


njoy frnds
ankit saxena

Comments or Responses

Login to post response