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)
{
}
}
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();
try
{
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.To="sanjuktin@gmail.com";
message.Subject = "Query from Ssquarenetizen student";
// You can specify Address directly as string
message.Bcc="gsauravjava@gmail.com";
//Body can be Html or text format
//Specify true if it is html message
message.BodyFormat=MailFormat.Html;
// Message body content
message.Body = txtquery.Text;
// Send SMTP mail
// smtpClient.Send(message);
SmtpMail.Send(message);
lblstatus.Text = "Email successfully sent.";
}
catch (Exception ex)
{
lblstatus.Text = "Send Email Failed." + ex.Message;
{
MailMessage message = new MailMessage();
try
{
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.To="sanjuktin@gmail.com";
message.Subject = "Query from Ssquarenetizen student";
// You can specify Address directly as string
message.Bcc="gsauravjava@gmail.com";
//Body can be Html or text format
//Specify true if it is html message
message.BodyFormat=MailFormat.Html;
// Message body content
message.Body = txtquery.Text;
// Send SMTP mail
// smtpClient.Send(message);
SmtpMail.Send(message);
lblstatus.Text = "Email successfully sent.";
}
catch (Exception ex)
{
lblstatus.Text = "Send Email Failed." + ex.Message;
}
}}