Exemplo n.º 1
0
 public void runner()
 {
     for (int i = 0; i < statistics.totalEmails; i++)
     {
         statistics.update(tnamess, temailss, tattachmentss);
         Thread.Sleep(1500);
         Internals.start(this, metroButton2, metroButton1, EMAIL, richTextBox1);
     }
     this.BeginInvoke(new Action(() =>
     {
         metroButton1.Visible = true;
         metroButton2.Visible = false;
     }));
 }
Exemplo n.º 2
0
        private void metroButton1_Click(object sender, EventArgs e)
        {
            forloooop = statistics.totalEmails * 2;
            forloooop = Convert.ToInt32(Interaction.InputBox("Enter the amount of emails you would like to send"));
            StringBuilder sb = new StringBuilder();

            if (Login.check() == true)
            {
                metroButton2.Visible = true;
                metroButton1.Visible = false;
                //    var thread2 = new Thread(new ThreadStart(runner));
                //   thread2.Start();
                for (int i = 0; i < forloooop + 1 - 1; i++)
                {
                    statistics.update(tnamess, temailss, tattachmentss);
                    ;
                    Internals.start(this, metroButton2, metroButton1, EMAIL, richTextBox1);


                    metroButton2.Visible = true;
                    metroButton1.Visible = false;
                    foreach (string newline in Form1.names.Split(new[] { '\n' }))
                    {
                        int index = Form1.names.IndexOf(Environment.NewLine);
                        Form1.names = Form1.names.Substring(index + Environment.NewLine.Length);
                        string[] splitter = newline.ToString().Split(' ');
                        Form1.cfnames = splitter[0];
                        Form1.clnames = splitter[1];
                        break;
                    }
                    foreach (string newline in Form1.emails.Split(new[] { '\n' }))//this returns one line at a time
                    {
                        int index = Form1.emails.IndexOf(Environment.NewLine);
                        Form1.emails  = Form1.emails.Substring(index + Environment.NewLine.Length);
                        Form1.cemails = newline.ToString();



                        EMAIL.Text = Form1.cemails.TrimEnd();

                        break;
                    }

                    //
                    sb.Append($"email:{EMAIL.Text} full name: {cfnames} {clnames}\n");
                    Internals.SendEmail(this, Form1.cfnames, Form1.clnames, cemails.TrimEnd(), Form1.attachments + @"" + Form1.attachnum.ToString() + ".pdf");
                    Logger.Log(richTextBox1, $"First:{Form1.cfnames}\nLast:{Form1.clnames}\nEmail:{Form1.cemails}\nAttachment location:{Form1.attachments + @"" + Form1.attachnum.ToString() + ".pdf"}");
                    // more variable work..
                    attachnum++;
                }
                string logfile = @"log\AutoMailer log; " + DateTime.Now.ToString("dddd, MMMM d, yyyy HH.mm.ss") + ".txt";
                Directory.CreateDirectory("log");
                File.CreateText(logfile);
                metroButton2.Visible = false;
                metroButton1.Visible = true;

                File.WriteAllText(logfile, richTextBox1.Text);
                MessageBox.Show(sb.ToString());;
            }
            else
            {
                MessageBox.Show("A login must be saved before you can start.");
            }
            //cattachments = $@"{attachments}\({attachnum}).pdf";
        }