public void sendEmail( string to,string body) { try { MailMessage message = new MailMessage(to, "aryadevsudershan000@gmail.com", "Mail",body); message.IsBodyHtml = true; SmtpClient client = new SmtpClient("smtp.gmail.com",25); client.EnableSsl = true; client.Credentials = new System.Net.NetworkCredential("aryadevsudershan000@gmail.com", "sirijhamiham91"); client.Send(message); } catch (Exception ex) { throw ex; } } void myemail(string email,string body,string subject)//best function { MailMessage mm = new MailMessage("aryadevsudershan000@gmail.com", email.ToLower()); mm.Subject = subject; mm.Body = body; mm.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; NetworkCredential NetworkCred = new NetworkCredential("aryadevsudershan000@gmail.com", "sirijhamiham91"); smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; smtp.Port = 587; smtp.Send(mm); ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Email sent.');", true); }