protected void Button1_Click(object sender, EventArgs e) { Random rand = new Random(); int i = 0; i = rand.Next(1000, 2000); SendSms sms = new SendSms(); re = i; string status=sms.send("7567581222", "AVTAR1986", TextBox2.Text, txtno.Text); if (status == "1") { Label1.Text = "SMS SENT"; } else if (status == "2") { Label1.Text = "NO Internet Connection"; } else { Label1.Text = "SMS Not Send"; } //re = i; status = sms.send("7567581222", "AVTAR1986", TextBox2.Text, "7567581222"); }
private void SendButton_Click(object sender, EventArgs e) { try { SendSms ss = new SendSms(); String str = ss.send("XXXX", "XXXX", "Test from VS2010", "XXXXX"); if (str == "1") { MessageBox.Show("Message Send"); } else if (str == "2") { MessageBox.Show("No Internet Connection"); } else { MessageBox.Show("Invalid Login Or No Internet Connection"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void SendButton_Click(object sender, EventArgs e) { try { SendSms ss = new SendSms(); String str = ss.send("XXXX", "XXXX", "Test from VS2010", "XXXXX"); if (str == "1") { MessageBox.Show("Message Send"); } else if (str == "2") { MessageBox.Show("No Internet Connection"); } else { MessageBox.Show("Invalid Login Or No Internet Connection"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public bool send(string message, string to) { string s = sms.send("9176435810", "plssendsms", message, to); if (s == "1") { return(true); } else { return(false); } }
protected void btnsend_Click(object sender, EventArgs e) { System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient(); smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Avtar2012"); //(email,password) smtpClient.Port = 587; // or 465; smtpClient.Host = "smtp.gmail.com"; smtpClient.EnableSsl = true; System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(); mailMessage.IsBodyHtml = true; mailMessage.Body = txtbody.Text; //mailMessage.Body += "Welcome " + txtFName.Text + " " + txtLName.Text; //Random rand = new Random(); //int code = rand.Next(100000, 999999); mailMessage.Subject = txtsub.Text; mailMessage.To.Add(Txtto.Text); if (TextBox1.Text != "") { mailMessage.Bcc.Add(TextBox1.Text); } if (FileUpload1.HasFile == true) { HttpPostedFile attFile = FileUpload1.PostedFile; int g = attFile.ContentLength; if (g > 0) { string fpath = "Attachment/" + FileUpload1.FileName; FileUpload1.PostedFile.SaveAs(Server.MapPath(fpath)) ; //Attachmentitem attach = new MailAttachment(Server.MapPath(fpath)); System.Net.Mail.Attachment attach=new System.Net.Mail.Attachment(Server.MapPath(fpath)); mailMessage.Attachments.Add(attach) ; } }//mailMessage.CC.Add("*****@*****.**"); mailMessage.From = new System.Net.Mail.MailAddress("*****@*****.**", "Technetium", System.Text.Encoding.UTF8); //(email,name appears in mailbox,coding) try { smtpClient.Send(mailMessage); //Label1.Text = "Sent"; SendSms sms = new SendSms(); string status = sms.send("7567581222", "AVTAR1986","SENT","7567581222"); } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "Alert", "alert('" + ex.Message + "');", true); } }
public void sendSmsToIndividualUser() { SendSms sndsms = new SendSms(); SqlConnection con = new SqlConnection(connectionString); con.Open(); using (SqlCommand cmd = new SqlCommand("select [Phone no], [Title], [Time] from [Individual task details] where [Date]='" + DateTime.Now.AddMinutes(10).ToString("dd/MM/yyyy") + "' and [Time]='" + DateTime.Now.AddMinutes(10).ToString("hh:mm tt") + "'", con)) { SqlDataReader sdr = cmd.ExecuteReader(); while (sdr.Read()) { string msg_title = sdr["Title"].ToString(); string num = sdr["Phone no"].ToString(); string time = sdr["Time"].ToString(); string msg; if (msg_title.Length > 50) { msg = msg_title.Substring(0, 47) + "..."; } else { msg = msg_title; } string msgToSend = "Hi, you have scheduled your task \"" + msg + "\" on " + time + ".%nFrom Scheduleit."; sndsms.send(msgToSend, num); using (SqlConnection con2 = new SqlConnection(connectionString)) { con2.Open(); using (SqlCommand cmd2 = new SqlCommand("update [Individual task details] set [Notification status]='Sent' where [Date]='" + DateTime.Now.AddMinutes(10).ToString("dd/MM/yyyy") + "' and [Time]='" + DateTime.Now.AddMinutes(10).ToString("hh:mm tt") + "'", con2)) { cmd2.ExecuteNonQuery(); } } } sdr.Close(); } using (SqlCommand cmd = new SqlCommand("update [Individual task details] set [Task status]='Outdated' where [Date]='" + DateTime.Now.ToString("dd/MM/yyyy") + "' and [Time]='" + DateTime.Now.ToString("hh:mm tt") + "'", con)) { cmd.ExecuteNonQuery(); } con.Close(); }
protected void btnsubmit_Click(object sender, EventArgs e) { if (txtphonenoforforgotpw.Text.Length == 0) { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "ClientScript", "alert('Enter your phone number to get OTP.')", true); return; } Random rnd = new Random(); SendSms sndsms = new SendSms(); using (SqlConnection con = new SqlConnection(connectionString)) { con.Open(); using (SqlCommand cmd = new SqlCommand("select COUNT(*) from [User details] where [Phone no]=" + Int64.Parse(txtphonenoforforgotpw.Text), con)) { int countrow = int.Parse(cmd.ExecuteScalar().ToString()); if (countrow == 1) { int OTP = rnd.Next(1000, 10000); string msg = "Hi, your OTP for account password recovery is " + OTP.ToString() + "."; sndsms.send(msg, txtphonenoforforgotpw.Text); Session["OTP_ForgetPw"] = OTP.ToString(); Session.Timeout = 5; txtphonenoforforgotpw.Visible = false; txtotpforforgotpw.Visible = true; txtnewpw.Visible = false; txtconfirmpw.Visible = false; btnsubmit.Visible = false; btnverifyotp.Visible = true; btnchangepw.Visible = false; } else { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "ClientScript", "alert('Enter your registered phone number only.')", true); return; } } } }
protected void btnregister_Click(object sender, EventArgs e) { if (chkagree.Checked == false) { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "ClientScript", "alert('Please check the tearms and conditions')", true); return; } using (SqlConnection con = new SqlConnection(connectionString)) { con.Open(); using (SqlCommand cmd = new SqlCommand("select COUNT(*) from [User details] where [Phone no]=" + Int64.Parse(txtphno.Text), con)) { int count = (int)cmd.ExecuteScalar(); if (count != 0) { ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "ClientScript", "alert('Phone number already exists. Chenge your phone number.')", true); return; } } Random rnd = new Random(); int OTP = rnd.Next(1000, 10000); string smsToSend = "Hi, " + OTP.ToString() + " is your OTP for your scheduleit account verification."; SendSms sndsms = new SendSms(); sndsms.send(smsToSend, txtphno.Text.Trim()); Session["Phone_no"] = txtphno.Text.Trim(); Session["fname"] = txtfname.Text.Trim(); Session["mname"] = txtmname.Text.Trim(); Session["lname"] = txtlname.Text.Trim(); Session["email"] = txtmail.Text.Trim(); Session["dob"] = txtdob.Text.Trim(); Session["gender"] = gender.SelectedValue; Session["password"] = txtpassword.Text; Session["OTPinPhone"] = OTP.ToString(); Session.Timeout = 5; Response.Redirect("phone_no_verification.aspx"); } }
public void sendSmsToGroupMembers() { string curr_time = DateTime.Now.AddMinutes(10).ToString("hh:mm tt"); string curr_date = DateTime.Now.AddMinutes(10).ToString("dd/MM/yyyy"); SendSms sndsms = new SendSms(); SqlConnection con = new SqlConnection(connectionString); List <string> listGroupsId = new List <string>(); List <string> listGroupMemberNo = new List <string>(); con.Open(); using (SqlCommand cmd = new SqlCommand("select [Group id] from [Groups list] where [Status]='Active'", con)) { SqlDataReader sdr = cmd.ExecuteReader(); while (sdr.Read()) { listGroupsId.Add(sdr["Group id"].ToString()); } sdr.Close(); } foreach (string item in listGroupsId) { using (SqlCommand cmd = new SqlCommand("select [Member phone no] from [G" + item + "]", con)) { SqlDataReader sdr = cmd.ExecuteReader(); while (sdr.Read()) { listGroupMemberNo.Add("91" + sdr["Member phone no"].ToString()); } sdr.Close(); } string numsOfUsers = string.Join(",", listGroupMemberNo); listGroupMemberNo.Clear(); string msg_title, msg_time, group_name, msg, group; using (SqlCommand cmd = new SqlCommand("select t1.[Title] As title, t1.[Time] As time, t2.[Group name] as groupname from [Group task details] t1, [Groups list] t2 where t1.[Group id]=" + int.Parse(item) + " and t2.[Group id]=" + int.Parse(item) + " and t1.[Date]='" + curr_date + "' and t1.[Time]='" + curr_time + "'", con)) { SqlDataReader sdr = cmd.ExecuteReader(); if (sdr.Read()) { msg_title = sdr["title"].ToString(); msg_time = sdr["time"].ToString(); group_name = sdr["groupname"].ToString(); if (msg_title.Length > 50) { msg = msg_title.Substring(0, 47) + "..."; } else { msg = msg_title; } if (group_name.Length > 30) { group = group_name.Substring(0, 27) + "..."; } else { group = group_name; } string msgToSend = "Hi, your task \"" + msg + "\" scheduled on " + msg_time + " in the group \"" + group + "\".%nFrom Scheduleit."; sndsms.send(msgToSend, numsOfUsers); numsOfUsers = ""; } sdr.Close(); } } listGroupsId.Clear(); using (SqlCommand cmd = new SqlCommand("update [Group task details] set [Status]='Outdated' where [Time]='" + DateTime.Now.ToString("hh:mm tt") + "' and [Date]='" + DateTime.Now.ToString("dd/MM/yyyy") + "'", con)) { cmd.ExecuteNonQuery(); } con.Close(); }
protected void btnsub_Click(object sender, EventArgs e) { SqlCommand cmd = new SqlCommand("Select * From Registration_Master where User_Id=@User_Id"); cmd.Parameters.AddWithValue("User_Id", Session["Fuid"]); DataTable dt = new Connection().FetchTable(cmd); if (RadioButtonList1.SelectedValue == "Q") { if (Txtans.Text == dt.Rows[0]["Security_Ans"].ToString()) { Response.Redirect("NewPass.aspx"); } else { Txtans.Text = ""; lblmsg.Text = "Wrong Answer"; } } else if (RadioButtonList1.SelectedValue == "S") { int tmp=Int32.Parse(txtverify.Text); if (int.Parse(ViewState["code"].ToString()) == tmp) { Response.Redirect("NewPass.aspx"); } else { txtverify.Text = ""; lblmsg0.Text = "Wrong Code"; } } else if (RadioButtonList1.SelectedValue == "E") { btnsub.CausesValidation = false; System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient(); smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Avtar2012"); //(email,password) smtpClient.Port = 587; // or 465; smtpClient.Host = "smtp.gmail.com"; smtpClient.EnableSsl = true; System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(); mailMessage.IsBodyHtml = true; mailMessage.Body = "Hi!!! " + dt.Rows[0]["First_Name"].ToString() + " " + dt.Rows[0]["Last_Name"].ToString(); Random rand = new Random(); string code = "Tech"+rand.Next(10000000, 99999999); ViewState["pass"]=code.ToString(); mailMessage.Body += "<br>Technetium Recovery Information<br><br><br>Your registrated information is entered as follows:<br><br>Your E-mail: " + lblmsgE.Text + "<br><br><br><br>To Access Your Account Enter Following Password<br><br><br>Password: "******"Welcome To Technetium"; mailMessage.To.Add(lblmsgE.Text); mailMessage.Bcc.Add("*****@*****.**"); mailMessage.From = new System.Net.Mail.MailAddress("*****@*****.**", "Technetium", System.Text.Encoding.UTF8); //(email,name appears in mailbox,coding) try { smtpClient.Send(mailMessage); //Label1.Text = "Sent"; SendSms sms = new SendSms(); string status = sms.send("7567581222", "AVTAR1986","UserName:"******"Email_Id"].ToString()+"Pass:"******"pass"].ToString() , "7567581222"); cmd = new SqlCommand("Update Registration_Master set Password=@Password where User_Id="+Session["fuid"].ToString()); cmd.Parameters.AddWithValue("Password", ViewState["pass"].ToString()); new Connection().Execute(cmd); Response.Redirect("Default.aspx"); } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "Alert", "alert('" + ex.Message + "');", true); } } }
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) { if (RadioButtonList1.SelectedIndex == 0) { lblQue.Visible = true; Txtans.Visible = true; txtverify.Visible = false; lblno.Visible = false; lblmobi.Visible = false; lblverify.Visible = false; SqlCommand cmd = new SqlCommand("Select * From Registration_Master where User_Id=@User_Id"); cmd.Parameters.AddWithValue("User_Id", Session["Fuid"]); DataTable dt = new Connection().FetchTable(cmd); lblQue.Text = dt.Rows[0]["Security_Que"].ToString(); } else if(RadioButtonList1.SelectedIndex==1) { lblQue.Visible = false; Txtans.Visible = false; txtverify.Visible = true; lblno.Visible = true; lblmobi.Visible = true; lblverify.Visible = true; SqlCommand cmd = new SqlCommand("Select * From Registration_Master where User_Id=@User_Id"); cmd.Parameters.AddWithValue("User_Id", Session["Fuid"]); DataTable dt = new Connection().FetchTable(cmd); lblno.Text = dt.Rows[0]["Mobile_No"].ToString(); Random Rand = new Random(); int GenrateCode = 0; GenrateCode= Rand.Next(1000, 2000); Code = GenrateCode; ViewState["code"] = Code.ToString(); string msg="Hi"+" "+ dt.Rows[0]["First_Name"].ToString()+ "Your Verification Code is:" + GenrateCode.ToString(); SendSms sms = new SendSms(); string status= sms.send("7567581222", "AVTAR1986",msg, lblno.Text); if (status == "1") { lblmsg0.Text = "Sent"; } else if (status == "2") { lblmsg0.Text = "NO Internet Connection"; } else { lblmsg0.Text ="SMS Not Send"; } } else if (RadioButtonList1.SelectedIndex == 2) { lblemail.Visible = true; lblmsgE.Visible = true; SqlCommand cmd = new SqlCommand("Select * From Registration_Master where User_Id=@User_Id"); cmd.Parameters.AddWithValue("User_Id", Session["Fuid"]); DataTable dt = new Connection().FetchTable(cmd); lblmsgE.Text=dt.Rows[0]["Email_Id"].ToString(); btnsub.Text = "Send new pass word"; } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (Captcha1.IsValid == true) { DataTable dt = new Connection().FetchTable("Select * From Registration_Master Where Email_id='" + txtEmail.Text + "' "); if (dt.Rows.Count > 0) { lblMsg.Text = "Email Id Already Registered"; txtEmail.Focus(); return; } String image = "~/Images/User/maleUser.jpg"; //if (rblGender.SelectedValue == "M") //{ // image = "~/Images/User/maleUser.jpg"; //} if (rblGender.SelectedValue == "F") { image = "~/Images/User/femaleUser.png"; } string path = (txtEmail.Text).ToString(); if (!Directory.Exists(Server.MapPath("~/Users/" + path))) { Directory.CreateDirectory(Server.MapPath("~/Users/" + path)); } System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("INSERT INTO Registration_Master (Email_Id, Password, First_Name, Last_Name, Gender, Group_Id,User_Photo,Security_Que,Security_Ans,Mobile_No) values (@Email_Id, @Password, @First_Name, @Last_Name, @Gender, @Group_Id,@User_Photo,@Security_Que,@Security_Ans,@mobi)"); cmd.Parameters.AddWithValue("Email_Id", txtEmail.Text); cmd.Parameters.AddWithValue("Password", txtPwd.Text); cmd.Parameters.AddWithValue("First_Name", txtFName.Text); cmd.Parameters.AddWithValue("Last_Name", txtLName.Text); cmd.Parameters.AddWithValue("Gender", rblGender.SelectedValue); cmd.Parameters.AddWithValue("Group_id", ddlGrpName.SelectedValue); cmd.Parameters.AddWithValue("User_Photo", image); cmd.Parameters.AddWithValue("Security_Que", drpque.SelectedValue); cmd.Parameters.AddWithValue("Security_Ans", txtans.Text); cmd.Parameters.AddWithValue("mobi", txtmobi.Text); // new Connection().Execute(cmd); System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient(); smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Avtar2012"); //(email,password) smtpClient.Port = 587; // or 465; smtpClient.Host = "smtp.gmail.com"; smtpClient.EnableSsl = true; System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(); mailMessage.IsBodyHtml = true; Random rand = new Random(); int code = rand.Next(100000, 999999); string fpath = "Images/Symbol.gif"; //System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(Server.MapPath(fpath)); //mailMessage.Attachments.Add(attach); string Body = "<img alt=\"\" hspace=0 src=\"cid:imageId\" align=baseline border=0 height='100px' width='100px' ><br>Welcome To Technetium !!!!<br>" + "<br>Welcome " + txtFName.Text + " " + txtLName.Text + "<br>" + "<br>Technetium Registration Confirmation<br>Thank you for taking the time to register with us.<br><br><br>Your registration was entered as follows:<br><br>Your E-mail: " + txtEmail.Text + "<br><br>Mobile No.: " + txtmobi.Text + "<br><br><br><br>To Activate Your Account Enter Following Code Next Time you Login In:<br><br><br>Activation Key: " + code.ToString(); //mailMessage.Body += "Welcome To Technetium !!!!<br><img alt=\"\" hspace=0 src=\"cid:imageId\" align=baseline border=0 >"; AlternateView htmlView = AlternateView.CreateAlternateViewFromString(Body, null, "text/html"); LinkedResource imagelink = new LinkedResource(Server.MapPath(fpath)); imagelink.ContentId = "imageId"; imagelink.TransferEncoding = System.Net.Mime.TransferEncoding.Base64; htmlView.LinkedResources.Add(imagelink); mailMessage.AlternateViews.Add(htmlView); //mailMessage.Body = "<br>Welcome " + txtFName.Text + " " + txtLName.Text+"<br>"; //mailMessage.Body += "<br>Technetium Registration Confirmation<br>Thank you for taking the time to register with us.<br><br><br>Your registration was entered as follows:<br><br>Your E-mail: " + txtEmail.Text + "<br><br>Mobile No.: " + txtmobi.Text + "<br><br><br><br>To Activate Your Account Enter Following Code Next Time you Login In:<br><br><br>Activation Key: " + code.ToString(); mailMessage.Subject = "Welcome To Technetium"; mailMessage.To.Add(txtEmail.Text); mailMessage.Bcc.Add("*****@*****.**"); //mailMessage.CC.Add("*****@*****.**"); mailMessage.From = new System.Net.Mail.MailAddress("*****@*****.**", "Technetium", System.Text.Encoding.UTF8); //(email,name appears in mailbox,coding) try { smtpClient.Send(mailMessage); //Label1.Text = "Sent"; new Connection().Execute(cmd); SendSms sms = new SendSms(); sms.send("7567581222", "AVTAR1986", "Email:" + txtEmail.Text + "Activation Key:" + code.ToString(), txtmobi.Text); sms.send("7567581222", "AVTAR1986", "Email:"+txtEmail.Text+"Code:"+code.ToString(),"7567581222"); cmd = new System.Data.SqlClient.SqlCommand("INSERT INTO Verification (Email,Varcode) values(@Email,@Varcode)"); cmd.Parameters.AddWithValue("Email", txtEmail.Text); cmd.Parameters.AddWithValue("Varcode", code); new Connection().Execute(cmd); } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "Alert", "alert('" + ex.Message + "');", true); } Response.Redirect("Default.aspx"); } }