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; using System.Net; public partial class forgotpwd : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { SmtpClient smtpClient = new SmtpClient(); smtpClient.Host = "smtp.gmail.com"; smtpClient.UseDefaultCredentials = false; smtpClient.EnableSsl = true; smtpClient.Credentials = new NetworkCredential("deepikam1608@gmail.com", "deepschinnu"); smtpClient.Port = 25; MailAddress fromAddress = new MailAddress("deepikam1608@gmail.com", "eoffice"); MailMessage message = new MailMessage(); message.From = fromAddress; int id = int.Parse(TextBox1.Text.ToString()); logic log = new logic(); string mail_id = log.get_manager_mail_id(id); message.To.Add(new MailAddress(mail_id)); message.Subject = "password of your eoffice account"; message.IsBodyHtml = true; string pwd = log.ret_pwd(id); string msg = "your password is.."+pwd; message.Body = msg; smtpClient.Send(message); Label1.Text = "Email successfully sent."; } }