using System.Net.Mail;
namespace webmail
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
MailMessage obj = new MailMessage();
obj.To.Add(TextBox1.Text);
obj.From = new MailAddress("susantakumardas1@gmail.com", "Susanta", System.Text.Encoding.UTF8);
obj.CC.Add(TextBox4.Text);
obj.From = new MailAddress("susantakumardas1@gmail.com", "Susanta", System.Text.Encoding.UTF8);
obj.Subject = TextBox2.Text;
obj.SubjectEncoding = System.Text.Encoding.UTF8;
obj.Body = TextBox3.Text;
obj.BodyEncoding = System.Text.Encoding.UTF8;
obj.IsBodyHtml = true;
obj.Priority = MailPriority.High;
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential("susantakumardas1@gmail.com", "password");
client.Port = 587;
client.Host = "smtp.gmail.com";
client.EnableSsl = true;
client.Send(obj);
Label4.Text = "mail sent";
}
catch (Exception e)
{
Label4 .Text ="Mail not send";
}
}
}