public void AppRemender()
        {
            try
            {
                DataTable Appdetails = new DataTable();
                SMSController smscont = new SMSController();
                Appdetails = smscont.AppRemender();

                DateTime re = Convert.ToDateTime("07:00");//Every Day at 7:00 AUS Time
                //DateTime re = Convert.ToDateTime("23:10");
                String ret = re.ToString("hh:mm");
                DateTime syst = DateTime.Now;
                string systime = syst.ToString("hh:mm");
                if (ret == systime)
                {
                    foreach (DataRow dr in Appdetails.Rows)
                    {
                        SMSView smsview = new SMSView();
                        int appid = Convert.ToInt32(dr["appointment_id"].ToString());
                        int custid = Convert.ToInt32(dr["appointment_customer_id"].ToString());
                        string cname = dr["customer_firstname"].ToString();
                        string appt = dr["appointment_time"].ToString();
                        int centreid = Convert.ToInt32(dr["appointment_centre_id"].ToString());
                        DateTime apt = Convert.ToDateTime(appt);
                        string cappt = apt.ToString("HH:mm");
                        string custaptime = apt.ToShortTimeString();
                        string mobnum = "61"+ dr["customer_mobile"].ToString();
                        string centrename;
                        if (centreid==1)
                        {
                            centrename = "Sydney";
                        }
                        else if (centreid == 58)
                        {
                            centrename = "Melbourne central";
                        }
                        else
                        {
                            centrename = "Highpoint";
                        }


                        string strmsg = "Dear " + cname + ",\r\nReminder your appointment with the Samsung Experience Store, " + centrename + " is at " + cappt + " today.\r\nPlease bring a copy of your purchase invoice and back-up your data before your appointment to avoid data loss, Looking forward to seeing you.";
                        //“Hi Kara, Reminder your appointment with the Samsung Experience Store, Sydney is at 11:15 today. Please bring a copy of your purchase invoice and back-up your data before your appointment to avoid data loss. Look forward to seeing you.”
                        smsview.SmsDesc = strmsg;
                        #region Samsung SMS gateway
                        //SMS for Samsung gateway
                        // Set the username of the account holder.
                        Messaging.MessageController.UserAccount.User = "******";
                        // Set the password of the account holder.
                        Messaging.MessageController.UserAccount.Password = "******";
                        // Set the first name of the account holder (optional).
                        Messaging.MessageController.UserAccount.ContactFirstName = "David";
                        // Set the last name of the account holder (optional).
                        Messaging.MessageController.UserAccount.ContactLastName = "Smith";
                        // Set the mobile phone number of the account holder (optional).
                        Messaging.MessageController.UserAccount.ContactPhone = "0423612367";
                        // Set the landline phone number of the account holder (optional).
                        Messaging.MessageController.UserAccount.ContactLandLine = "0338901234";
                        // Set the contact email of the account holder (optional).
                        Messaging.MessageController.UserAccount.ContactEmail = "*****@*****.**";
                        // Set the country of origin of the account holder (optional).
                        Messaging.MessageController.UserAccount.Country = Countries.Australia;
                        bool testOK = true;

                        try
                        {
                            // Test the user account settings.
                            Account testAccount = Messaging.MessageController.UserAccount;
                            testOK = Messaging.MessageController.TestAccount(testAccount);
                        }
                        catch (Exception ex)
                        {
                            // An exception was thrown. Display the details of the exception and return.
                            string message = "There was an error testing the connection details:\n" +
                            ex.Message;
                            // MessageBox.Show(this, message, "Connection Failed", MessageBoxButtons.OK);
                            return;
                        }
                        if (testOK)
                        {
                            // The user account settings were valid. Display a success message
                            // box with the number of credits.
                            int balance = Messaging.MessageController.UserAccount.Balance;
                            string message = string.Format("You have {0} message credits available.",
                            balance);
                            // MessageBox.Show(this, message, "Connection Succeeded", MessageBoxButtons.OK);
                        }
                        else
                        {
                            // The username or password were incorrect. Display a failed message box.
                            //  MessageBox.Show(this, "The username or password you entered were incorrect.",
                            // "Connection Failed", MessageBoxButtons.OK);
                        }

                        Messaging.MessageController.Settings.TimeOut = 60;
                        // Set the batch size (number of messages to be sent at once) to 200.
                        Messaging.MessageController.Settings.BatchSize = 200;
                        //string strmsg = "To confirm an appointment with the Samsung Experience Store,\r\nyou will need 4 characters password. The password is  " + strrandom + "";
                        //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                        //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                        //string strmsg = "Hi" + " " + Cname + ",Your ticket number is:" + QueueTokenGenerationSMS + " . Thanks";

                        //"Hi Kara, your ticket number is 040, Approximate waiting time is 00:40 minutes/hours”

                        Messaging.MessageController.Settings.DeliveryReport = true;
                        SMSMessage smsobj = new SMSMessage(mobnum, strmsg);
                        Messaging.MessageController.AddToQueue(smsobj);
                        Messaging.MessageController.SendMessages();
                        //end of Samsung SMS

                        //smsview.SmsUpdatedDateTime = System.DateTime.Now;
                        //smsview.SmsActive = 'Y';
                        //smsview.SMSContentTypeId = 1;
                        //smsview.SmsAlert = 1;
                        //smsview.SmsUpdatedBy="Admin";
                        //string i;
                        //i = smscontroller.getInsertAppointmentAlertSms(smsview);
                        #endregion Samsung SMS gateway

                        #region Update SMS_Alert statsus flag

                        smsview.AppointmentID = appid;
                        smsview.SMSalert = 'B';
                        smscont.updatesmsalert(smsview);
                        #endregion Update SMS_Alert statsus flag
                        
                        #region inserting to tbl_sms_tnx
                        smsview.CustId = custid;
                        smsview.SmsDesc = strmsg;
                        smsview.PhoneNo = mobnum;
                        smsview.DeliveryReport = "y";
                        smsview.SmsDesc = strmsg;
                        smsview.IncomingsmsFlag = "M";
                        smsview.SmsVisittnxId = 2;
                        smsview.SMSDateTime = System.DateTime.Now;
                        smsview.SMSStatusFlag = "M";
                        smsview.QueueNo = Convert.ToString("1");
                        smsview.CentreId = "";
                        smsview.SMSDateTime = System.DateTime.Now;
                        string i;
                        i = smscontroller.getInsertAppointmentAlertSms(smsview);
                       #endregion into tbl_sms_tnx
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }