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.Net;
using System.Net.Mail;
public partial class _Default : System.Web.UI.Page
{
string type;
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Enabled = false;
TextBox2.Enabled = false;
TextBox3.Enabled = false;
TextBox4.Enabled = false;
TextBox5.Enabled = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
if (DropDownList1.SelectedValue == "gmail")
{
type = "smtp.gmail.com";
}
else
{
type = "smtp.live.com";
}
MailMessage msg = new MailMessage();
msg.From = new MailAddress(TextBox1.Text);
msg.To.Add(TextBox2.Text);
msg.Subject = TextBox4.Text;
msg.Body = TextBox3.Text;
SmtpClient sc = new SmtpClient(type);
sc.Port = 25;
sc.Credentials = new NetworkCredential(TextBox1.Text, TextBox5.Text);
sc.EnableSsl = true;
sc.Send(msg);
Response.Write("Mail sent");
}
catch (Exception e1)
{
Response.Write(e1.Message);
}
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Enabled = true;
TextBox2.Enabled = true;
TextBox3.Enabled = true;
TextBox4.Enabled = true;
TextBox5.Enabled = true;
}
}
If u want to send to multiple people..just add a loop in the MailMessage section upto Response.Write("Mail sent");
Accept as answer if it solves your problem