Smtp Mail
Sun Oct 12 2025 17:37:00 GMT+0000 (Coordinated Universal Time)
Saved by
@final
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
namespace TASK11
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
MailMessage mail = new MailMessage();
mail.To.Add(TextBox1.Text);
mail.From = new MailAddress("youremail@domain.com"); // Replace with your email
mail.Subject = TextBox2.Text;
mail.Body = TextBox3.Text;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; // Replace with your SMTP server
smtp.Port = 587; // Replace with SMTP port
smtp.Credentials = new System.Net.NetworkCredential("username", "password"); // Replace with your credentials
smtp.EnableSsl = true;
smtp.Send(mail);
Label4.Text = "Email sent successfully!";
}
catch (Exception ex)
{
Label4.Text = "Error: " + ex.Message;
}
}
}
}
content_copyCOPY
Comments