void loadValues(string titolo)
        {
            int count = 0;


            try
            {
                db = new SQLiteDatabase();
                System.Data.DataTable recipe;
                String query = "select * from tblGroup where groupName = '" + titolo + "'";
                recipe = db.GetDataTable(query);
                // The results can be directly applied to a DataGridView control

                foreach (DataRow r in recipe.Rows)
                {
                    count            += 1;
                    txtGroupName.Text = r["groupName"].ToString();
                }
            }
            catch (Exception fail)
            {
                String error = "The following error has occurred:\n\n";
                error += fail.Message.ToString() + "\n\n";
                MessageBox.Show(error);
                this.Close();
            }
            if (count == 0)
            {
                txtList.Enabled = false;
            }
        }
Exemple #2
0
        void loadAccounts()
        {
            int count = 0;

            listBox1.Items.Clear();

            try
            {
                db = new SQLiteDatabase();
                DataTable recipe;
                String    query = "select title from tblEmailAccount";
                recipe = db.GetDataTable(query);
                // The results can be directly applied to a DataGridView control

                foreach (DataRow r in recipe.Rows)
                {
                    count += 1;
                    listBox1.Items.Add(r["title"].ToString());
                }
            }
            catch (Exception fail)
            {
                String error = "The following error has occurred:\n\n";
                error += fail.Message.ToString() + "\n\n";
                MessageBox.Show(error);
                this.Close();
            }
            if (count == 0)
            {
                listBox1.Enabled  = false;
                btnDelete.Enabled = false;
                btnEdit.Enabled   = false;
            }
        }
        void loadAccounts()
        {
            int count = 0;

            txtList.Items.Clear();


            try
            {
                db = new SQLiteDatabase();
                System.Data.DataTable recipe;
                String query = "select * from tblGroup";
                recipe = db.GetDataTable(query);


                foreach (DataRow r in recipe.Rows)
                {
                    count += 1;
                    txtList.Items.Add(r["groupname"].ToString());
                }
            }
            catch (Exception fail)
            {
                String error = "The following error has occurred:\n\n";
                error += fail.Message.ToString() + "\n\n";
                MessageBox.Show(error);
                this.Close();
            }
            if (count == 0)
            {
                txtList.Enabled   = false;
                panelMain.Enabled = false;
            }
        }
Exemple #4
0
        private void txtAccountList_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                db = new SQLiteDatabase();
                System.Data.DataTable recipe;
                String query = "select * from tblEmailAccount where title = '" + txtAccountList.SelectedItem.ToString() + "'";
                recipe = db.GetDataTable(query);


                foreach (DataRow r in recipe.Rows)
                {
                    credentialpassword = r["password"].ToString();
                    SupersmtpServer    = r["smtp"].ToString();
                    fromAddress        = r["username"].ToString();
                    fromName           = r["fullname"].ToString();
                }

                btnSend.Enabled = true;
            }
            catch (Exception fail)
            {
                String error = "The following error has occurred:\n\n";
                error += fail.Message.ToString() + "\n\n";
                MessageBox.Show(error);
                this.Close();
                btnSend.Enabled = false;
            }
        }
Exemple #5
0
        public void loadAccounts()
        {
            int count = 0;

            txtAccountList.Items.Clear();
            txtAccountList.Text = "";
            try
            {
                db = new SQLiteDatabase();
                System.Data.DataTable recipe;
                String query = "select title from tblEmailAccount";
                recipe = db.GetDataTable(query);
                // The results can be directly applied to a DataGridView control

                foreach (DataRow r in recipe.Rows)
                {
                    count += 1;
                    txtAccountList.Items.Add(r["title"].ToString());
                    label2.Text = "Please provide a valid Mail Server";
                }
            }
            catch (Exception fail)
            {
                String error = "The following error has occurred:\n\n";
                error += fail.Message.ToString() + "\n\n";
                MessageBox.Show(error);
                this.Close();
            }
            if (count == 0)
            {
                label2.Text            = "No Server account found.";
                btnSend.Enabled        = false;
                txtAccountList.Enabled = false;
            }
            else
            {
                label2.Text            = "Ready";
                btnSend.Enabled        = true;
                txtAccountList.Enabled = true;
            }
        }
Exemple #6
0
        void loadValues(string titolo)
        {
            int count = 0;


            try
            {
                db = new SQLiteDatabase();
                DataTable recipe;
                String    query = "select * from tblEmailAccount where title = '" + titolo + "'";
                recipe = db.GetDataTable(query);
                // The results can be directly applied to a DataGridView control

                foreach (DataRow r in recipe.Rows)
                {
                    count              += 1;
                    txtTitle.Text       = r["title"].ToString();
                    txtAccountName.Text = r["title"].ToString();
                    txtEmail.Text       = r["username"].ToString();
                    txtFullName.Text    = r["fullname"].ToString();
                    txtPassword.Text    = r["password"].ToString();
                    txtSMTPServer.Text  = r["smtp"].ToString();
                    btnDelete.Enabled   = true;
                    btnEdit.Enabled     = true;
                }
            }
            catch (Exception fail)
            {
                String error = "The following error has occurred:\n\n";
                error += fail.Message.ToString() + "\n\n";
                MessageBox.Show(error);
                this.Close();
            }
            if (count == 0)
            {
                listBox1.Enabled  = false;
                btnDelete.Enabled = false;
                btnEdit.Enabled   = false;
            }
        }
        void loadGrid(string titolo)
        {
            try
            {
                db = new SQLiteDatabase();
                System.Data.DataTable mailz;
                String query = "select Name \"Name\" , Email \"E-Mail\", CompanyName \"Company Name\" from tblEmail where groupName = '" + titolo + "'";
                mailz = db.GetDataTable(query);

                dataGridView1.DataSource = mailz;

                /*
                 * // Or looped through for some other reason
                 * foreach (DataRow r in recipe.Rows)
                 * {
                 *  MessageBox.Show(r["Name"].ToString());
                 *  MessageBox.Show(r["Description"].ToString());
                 *  MessageBox.Show(r["Prep Time"].ToString());
                 *  MessageBox.Show(r["Cooking Time"].ToString());
                 * }
                 *
                 */
                dataGridView1.Columns[0].Width = 120;
                dataGridView1.Columns[1].Width = 120;
                dataGridView1.Columns[0].Width = 120;
                try
                {
                    int xxx = dataGridView1.RowCount - 1;
                    txtTotal.Text = "Total Records : " + xxx.ToString();
                }
                catch { }
            }
            catch (Exception fail)
            {
                String error = "The following error has occurred:\n\n";
                error += fail.Message.ToString() + "\n\n";
                MessageBox.Show(error);
                this.Close();
            }
        }
Exemple #8
0
        private void txtList_SelectedIndexChanged(object sender, EventArgs e)
        {
            int count = 0;

            try
            {
                db = new SQLiteDatabase();
                System.Data.DataTable recipe;
                String query = "select count(*) as xxx from tblemail where groupname = '" + txtList.SelectedItem.ToString() + "'";
                recipe = db.GetDataTable(query);


                foreach (DataRow r in recipe.Rows)
                {
                    count        += 1;
                    txtCount.Text = r["xxx"].ToString();
                }
            }
            catch (Exception fail)
            {
                String error = "The following error has occurred:\n\n";
                error += fail.Message.ToString() + "\n\n";
                MessageBox.Show(error);
                this.Close();
            }


            try
            {
                totz = Convert.ToInt32(txtCount.Text);
            }
            catch
            {
                totz = 0;
            }
        }
Exemple #9
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            Int32 overallTotal;

            string tps = "";
            int    cnt = 0;


            overallTotal = cnt + totz;
            int   index = 0;
            int   total = overallTotal;
            int   count = 0;
            float ptst  = 0;

            tt = 0;

            #region ExcelImport ---
            if (fileName != "" && fileName.Contains(".xls"))
            {
                Microsoft.Office.Interop.Excel.ApplicationClass app      = new ApplicationClass();
                Microsoft.Office.Interop.Excel.Workbook         workBook = app.Workbooks.Open(fileName, 0, true, 5,
                                                                                              "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows,
                                                                                              "\t", false, false, 0, true, 1, 0);
                Microsoft.Office.Interop.Excel.Worksheet workSheet = (Microsoft.Office.Interop.Excel.Worksheet)workBook.ActiveSheet;
                int nInLastRow = workSheet.Cells.Find("*", System.Reflection.Missing.Value,
                                                      System.Reflection.Missing.Value, System.Reflection.Missing.Value, Microsoft.Office.Interop.Excel.XlSearchOrder.xlByRows, Microsoft.Office.Interop.Excel.XlSearchDirection.xlPrevious, false, System.Reflection.Missing.Value, System.Reflection.Missing.Value).Row;



                object rowIndex  = 1;
                object colIndex1 = 1;
                object colIndex2 = 2;

                overallTotal += nInLastRow;

                total = overallTotal;


                string newtext = "";

                string message = mymessage;
                while (((Microsoft.Office.Interop.Excel.Range)workSheet.Cells[rowIndex, colIndex1]).Value2 != null)
                {
                    rowIndex = 2 + index;
                    PTS      = "";

                    try
                    {
                        string firstName = ((Microsoft.Office.Interop.Excel.Range)workSheet.Cells[rowIndex, colIndex1]).Value2.ToString();
                        string email     = ((Microsoft.Office.Interop.Excel.Range)workSheet.Cells[rowIndex, colIndex2]).Value2.ToString();

                        if (SendMail(email, message, globalSubject, fromName, ""))
                        {
                            newtext = firstName + ", " + email + " --> Email Sent!\r\n";
                            tt     += 1;
                        }
                        else
                        {
                            newtext = firstName + ", " + email + " --> Email Failed!\r\n";
                            listBox1.Items.Add(email);
                        }
                    }
                    catch (Exception ex)
                    {
                        //PTS += @"\r\nError Occured : Index " + index.ToString() + " --> " + ex.Message.ToString() + @"\r\n";
                    }
                    index++;
                    count++;

                    ptst  = count * 100;
                    ptst /= total;

                    int val = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(ptst)));
                    bw1.ReportProgress(val, newtext);
                }
            }
            #endregion

            #region EmailList

            if (totz > 0)
            {
                //try
                //{
                db = new SQLiteDatabase();
                System.Data.DataTable recipe;
                String query = "select * from tblemail where groupname = '" + smtpTitle + "'";
                recipe = db.GetDataTable(query);

                total = totz;
                count = 0;
                index = 0;
                ptst  = 0;

                string newText = "";

                foreach (DataRow r in recipe.Rows)
                {
                    PTS = "";
                    string em = "", nm = "";
                    em = r["email"].ToString();
                    nm = r["name"].ToString();

                    try
                    {
                        if (SendMail(r["email"].ToString(), mymessage, globalSubject, fromName, ""))
                        {
                            newText = r["name"].ToString() + ", " + r["email"].ToString() + " --> Email Sent!\r\n";
                        }
                        else
                        {
                            newText = r["name"].ToString() + ", " + r["email"].ToString() + " --> Email Failed!\r\n";
                            listBox1.Items.Add(r["email"].ToString());
                        }
                    }

                    catch (Exception ex)
                    {
                        // newText += @"\r\nError Occured : Index " + index.ToString() + " --> " + ex.Message.ToString() + @"\r\n";
                        newText = "";
                    }

                    tt += 1;
                    index++;
                    count++;

                    ptst  = count * 100;
                    ptst /= total;

                    PTS = em + "\r\n";

                    int val = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(ptst)));
                    bw1.ReportProgress(val, newText);
                }


                //}
                //catch (Exception fail)
                //{
                //    PTS += @"\r\n" + fail.Message.ToString() + "\r\n";

                //}
            }

            #endregion

            #region ManualEnter

            if (totList != "")
            {
                try
                {
                    tps = totList;

                    string[] words = tps.Split(',');

                    total = words.Length;
                    count = 0;
                    string newtext = "";

                    foreach (string word in words)
                    {
                        if (SendMail(word.Trim(), mymessage, globalSubject, fromName, ""))
                        {
                            newtext = word.Trim() + ", " + word.Trim() + " --> Email Sent!\r\n";
                            tt     += 1;
                        }
                        else
                        {
                            newtext = word.Trim() + ", " + word.Trim() + " --> Email Failed!\r\n";
                            listBox1.Items.Add(word.Trim());
                        }


                        index++;
                        count++;

                        ptst  = count * 100;
                        ptst /= total;

                        int val = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(ptst)));
                        bw1.ReportProgress(val, newtext);
                    }
                }
                catch (Exception op)
                {
                    PTS += @"\r\n" + op.Message + @"\r\n";
                }
            }

            #endregion
        }