Sunday, 27 November 2011

Email Sending Or FeedBack Form

Code To  Be Done At Submit Button:-

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web.Mail;
public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)

    protected void SubmitButton_Click(object sender, EventArgs e)
        MailMessage message = new MailMessage();

            string fromAddress =txtmail.Text+" "+ txtname.Text;

            // You can specify the host name or ipaddress of your server

            // Default in IIS will be localhost

            SmtpMail.SmtpServer = "";

            //From address will be given as a MailAddress Object

            message.From = fromAddress;

            // To address collection of MailAddress

            message.Subject = "Query from Ssquarenetizen student";


            // You can specify Address directly as string


            //Body can be Html or text format

            //Specify true if it  is html message


            // Message body content

            message.Body = txtquery.Text;

            // Send SMTP mail

           // smtpClient.Send(message);

            lblstatus.Text = "Email successfully sent.";
        catch (Exception ex)
            lblstatus.Text = "Send Email Failed." + ex.Message;