protected void btnEmail_Click(object sender, EventArgs e) { if (chkemail.Checked) { dbcon obj = new dbcon(); try { MailMessage mail = new MailMessage(); if (obj.getUserPassword(txtusername.Text)) { mail.To.Add(dbcon.email); mail.From = new MailAddress("*****@*****.**"); mail.Subject = "Password Recovery"; string Body = dbcon.body; //myclass.body; //"using Gmail in ASP.NET"; mail.Body = Body; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential ("*****@*****.**", "shoppingcart"); smtp.EnableSsl = true; smtp.Send(mail); lblemail.Text = "Dear User Your Password is Sent to your Email Address"; } } catch (Exception ex) { lblemail.Text = "some Problem" + ex; } } if (chkmobile.Checked) { dbcon obj = new dbcon(); try { if (obj.getUserPassword(txtusername.Text)) { string MsgBody = dbcon.body; //myclass.body; //"using Gmail in ASP.NET"; int port = 8; int baud = 9600; int time = 300; GsmCommMain Rate = new GsmCommMain(port, baud, time); Rate.Open(); while (!Rate.IsConnected()) { lblemail.Text = "Not Connected"; } //MessageBox.Show("Connected"); // Rate.Close(); SmsSubmitPdu Msg; Msg = new SmsSubmitPdu(MsgBody, dbcon.mobile); Rate.SendMessage(Msg); lblemail.Text = "Message sent to " + dbcon.mobile + ""; Rate.Close(); // lblemail.Text = "Dear User Your Password is Sent to your Email Address"; } } catch (Exception ex) { txtusername.Text = "some Problem" + ex; } } }