protected void confirmButton_Click(object sender, EventArgs e) { bool test1 = RadioButton1.Checked; bool test2 = RadioButton2.Checked; DAL.Model.Feedback aFeedback = new DAL.Model.Feedback(); string masg; if (test1) { aFeedback.Status = "Yes"; } else { aFeedback.Status = "No"; } aFeedback.Location = pickupTextBox.Text; aFeedback.FromDate = fromDateTextBox.Text; aFeedback.ToDate = toDateTextBox.Text; aFeedback.StudentId = StudentLogin.Class1.storevalue; aFeedback.Gender = studentLoginManager.StudentGender(aFeedback.StudentId); if (!test1 && !test2) { statusLabel.Text = "Please Select Yes or No as Your status"; masg = ""; } else { masg = feedbackManager.Save(aFeedback); statusLabel.Text = ""; } if (masg == "Successful!!" && aFeedback.Status == "Yes") { SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Sha@1234"); smtp.EnableSsl = true; MailMessage msg = new MailMessage(); msg.Subject = "Hello " + nameTextBox.Text; msg.Body = "Hi You are eligible for bus From " + "\n" + " Date : " + fromDateTextBox.Text + " To Date : " + toDateTextBox.Text + "\n" + "Location :" + pickupTextBox.Text; string toaddress = emailTextBox.Text; msg.To.Add(toaddress); string fromaddress = "IIUC Transport Division <*****@*****.**>"; msg.From = new MailAddress(fromaddress); try { smtp.Send(msg); outputLabel.Text = "Successfull!!"; } catch { throw; } } else { outputLabel.Text = masg; } }