System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(); msg.From = new MailAddress(emailid.Text); msg.To.Add("[email protected]"); msg.Subject = subject.Text; msg.Body = txtBody.Text; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "mygmailpassword"); smtp.EnableSsl = true; smtp.Send(msg);