diff --git a/App.config b/App.config new file mode 100644 index 0000000..e68aba0 --- /dev/null +++ b/App.config @@ -0,0 +1,18 @@ + + + + +
+ + + + + + + + + tabControl1 + + + + \ No newline at end of file diff --git a/Form1.Designer.cs b/Form1.Designer.cs new file mode 100644 index 0000000..5ae82a0 --- /dev/null +++ b/Form1.Designer.cs @@ -0,0 +1,268 @@ +namespace MailSender +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.button1 = new System.Windows.Forms.Button(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.richTextBox2 = new System.Windows.Forms.RichTextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.fromMailTextBox = new System.Windows.Forms.TextBox(); + this.passwordTextBox = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.HostTextBox = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.PortTextBox = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.timeOutTextBox = new System.Windows.Forms.TextBox(); + this.tabControl1.SuspendLayout(); + this.tabPage1.SuspendLayout(); + this.SuspendLayout(); + // + // tabControl1 + // + this.tabControl1.Controls.Add(this.tabPage1); + this.tabControl1.Location = new System.Drawing.Point(12, 12); + this.tabControl1.Multiline = true; + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(338, 305); + this.tabControl1.TabIndex = 0; + // + // tabPage1 + // + this.tabPage1.Controls.Add(this.timeOutTextBox); + this.tabPage1.Controls.Add(this.label3); + this.tabPage1.Controls.Add(this.PortTextBox); + this.tabPage1.Controls.Add(this.label2); + this.tabPage1.Controls.Add(this.HostTextBox); + this.tabPage1.Controls.Add(this.label1); + this.tabPage1.Controls.Add(this.label6); + this.tabPage1.Controls.Add(this.passwordTextBox); + this.tabPage1.Controls.Add(this.fromMailTextBox); + this.tabPage1.Controls.Add(this.label4); + this.tabPage1.Controls.Add(this.comboBox1); + this.tabPage1.Controls.Add(this.button1); + this.tabPage1.Controls.Add(this.textBox2); + this.tabPage1.Controls.Add(this.textBox1); + this.tabPage1.Location = new System.Drawing.Point(4, 22); + this.tabPage1.Name = "tabPage1"; + this.tabPage1.Padding = new System.Windows.Forms.Padding(3); + this.tabPage1.Size = new System.Drawing.Size(330, 279); + this.tabPage1.TabIndex = 0; + this.tabPage1.Text = "Setup"; + this.tabPage1.UseVisualStyleBackColor = true; + // + // comboBox1 + // + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Location = new System.Drawing.Point(7, 59); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(317, 21); + this.comboBox1.TabIndex = 3; + this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(234, 217); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(90, 38); + this.button1.TabIndex = 2; + this.button1.Text = "Start"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // textBox2 + // + this.textBox2.Location = new System.Drawing.Point(7, 32); + this.textBox2.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(317, 20); + this.textBox2.TabIndex = 1; + this.textBox2.Text = "ttt.txt"; + this.textBox2.MouseClick += new System.Windows.Forms.MouseEventHandler(this.textBox2_MouseClick); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(7, 6); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(317, 20); + this.textBox1.TabIndex = 0; + this.textBox1.Text = "Proba subject #"; + this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); + // + // timer1 + // + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // richTextBox1 + // + this.richTextBox1.Location = new System.Drawing.Point(356, 34); + this.richTextBox1.Name = "richTextBox1"; + this.richTextBox1.Size = new System.Drawing.Size(96, 283); + this.richTextBox1.TabIndex = 1; + this.richTextBox1.Text = ""; + this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged); + // + // richTextBox2 + // + this.richTextBox2.Location = new System.Drawing.Point(458, 34); + this.richTextBox2.Name = "richTextBox2"; + this.richTextBox2.Size = new System.Drawing.Size(207, 283); + this.richTextBox2.TabIndex = 2; + this.richTextBox2.Text = ""; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(5, 94); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(54, 13); + this.label4.TabIndex = 4; + this.label4.Text = "Your Mail:"; + // + // fromMailTextBox + // + this.fromMailTextBox.Location = new System.Drawing.Point(65, 87); + this.fromMailTextBox.Name = "fromMailTextBox"; + this.fromMailTextBox.Size = new System.Drawing.Size(259, 20); + this.fromMailTextBox.TabIndex = 5; + // + // passwordTextBox + // + this.passwordTextBox.Location = new System.Drawing.Point(65, 113); + this.passwordTextBox.Name = "passwordTextBox"; + this.passwordTextBox.Size = new System.Drawing.Size(258, 20); + this.passwordTextBox.TabIndex = 8; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(4, 116); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(56, 13); + this.label6.TabIndex = 9; + this.label6.Text = "Password:"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(8, 142); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(53, 13); + this.label1.TabIndex = 10; + this.label1.Text = "Host mail:"; + // + // HostTextBox + // + this.HostTextBox.Location = new System.Drawing.Point(65, 139); + this.HostTextBox.Name = "HostTextBox"; + this.HostTextBox.Size = new System.Drawing.Size(258, 20); + this.HostTextBox.TabIndex = 11; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(8, 168); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(54, 13); + this.label2.TabIndex = 12; + this.label2.Text = "Port Num:"; + // + // PortTextBox + // + this.PortTextBox.Location = new System.Drawing.Point(64, 165); + this.PortTextBox.Name = "PortTextBox"; + this.PortTextBox.Size = new System.Drawing.Size(258, 20); + this.PortTextBox.TabIndex = 13; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(9, 194); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(53, 13); + this.label3.TabIndex = 14; + this.label3.Text = "Time Out:"; + // + // timeOutTextBox + // + this.timeOutTextBox.Location = new System.Drawing.Point(64, 191); + this.timeOutTextBox.Name = "timeOutTextBox"; + this.timeOutTextBox.Size = new System.Drawing.Size(258, 20); + this.timeOutTextBox.TabIndex = 15; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(677, 330); + this.Controls.Add(this.richTextBox2); + this.Controls.Add(this.richTextBox1); + this.Controls.Add(this.tabControl1); + this.Name = "Form1"; + this.Text = "Form1"; + this.Load += new System.EventHandler(this.Form1_Load); + this.tabControl1.ResumeLayout(false); + this.tabPage1.ResumeLayout(false); + this.tabPage1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.RichTextBox richTextBox1; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.RichTextBox richTextBox2; + private System.Windows.Forms.TextBox fromMailTextBox; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.TextBox passwordTextBox; + private System.Windows.Forms.TextBox HostTextBox; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox PortTextBox; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox timeOutTextBox; + } +} + diff --git a/Form1.cs b/Form1.cs new file mode 100644 index 0000000..bd63f74 --- /dev/null +++ b/Form1.cs @@ -0,0 +1,167 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Net.Mail; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace MailSender +{ + public partial class Form1 : Form + { + public List someFiles; + + public Form1() + { + InitializeComponent(); + + + + passwordTextBox.PasswordChar = '*'; + } + + private void textBox1_TextChanged(object sender, EventArgs e) + { + + } + + public void textBox2_MouseClick(object sender, MouseEventArgs e) + { + + } + + private void button1_Click(object sender, EventArgs e) + { + comboBox1.SelectedText = comboBox1.SelectedText.Replace("\n", ""); + comboBox1.SelectedText = comboBox1.SelectedText.Replace("\r", ""); + + someFiles = File.ReadAllLines(textBox2.Text).ToList(); + richTextBox2.AppendText("Mail list loaded into memory !"+ Environment.NewLine); + comboBox1.SelectedIndex = 0; + + if (comboBox1.SelectedItem == null) + { + timer1.Interval = Convert.ToInt16(comboBox1.GetItemText("900")) * 1000; + } + + timer1.Enabled = true; + timer1.Interval = Convert.ToInt16(comboBox1.GetItemText("900")) * 1000; + timer1.Interval = 900000; + // timer1.Interval = 600; + + + richTextBox2.AppendText("sending interval set to : " + timer1.Interval.ToString()+Environment.NewLine); + } + + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + + } + + private void Form1_Load(object sender, EventArgs e) + { + comboBox1.Items.Add("60"); + } + + private void timer1_Tick(object sender, EventArgs e) + { + string line = ""; + int counter = -1; + int flag = 0; + try { + // timer1.Enabled = false; + string Subject = textBox1.Text; + + string body; + + //var logFile = File.ReadAllLines(textBox2.Text);//eto + //someFiles = new List(logFile);//tezi dve linii dobavih + foreach (string item in someFiles)//initialize the list from file before first use from the upper two lines + { + counter++; + + // byte[] bytes1 = Encoding.Default.GetBytes(item); + //String lin1 = Encoding.UTF8.GetString(bytes1); + String lin1 = item; + + if (!item.Contains("Processed")) + { + flag = 1; + line = lin1; + break; + } + + } + if (flag == 1) + { + string[] arrayList = line.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); + //MessageBox.Show(arrayList[1]); + + // Formata na imeto e slednata: ime; mail; grad;adress + + + Subject = textBox1.Text.Replace("#", arrayList[0]); + body = richTextBox1.Text; + body = body.Replace("#", arrayList[0]); + body = body.Replace("&", arrayList[2]); + body = body.Replace("^", arrayList[3]); + + SmtpClient client = new SmtpClient(); + // client.Port = Convert.ToInt32(textBox1.Text); + + client.Host = HostTextBox.Text; + client.Port = Convert.ToInt32(PortTextBox.Text); + client.EnableSsl = false; + client.Timeout = Convert.ToInt32(timeOutTextBox.Text); + client.DeliveryMethod = SmtpDeliveryMethod.Network; + client.UseDefaultCredentials = false; + client.Credentials = new System.Net.NetworkCredential(fromMailTextBox.Text, passwordTextBox.Text); + arrayList[1].Replace("\t",""); + arrayList[1].Replace("\n", ""); + arrayList[1].Replace(" ", ""); + arrayList[1].Replace("\r", ""); + + + MailMessage mail = new MailMessage(Convert.ToString(fromMailTextBox.Text), arrayList[1], Subject, body); + mail.BodyEncoding = UTF8Encoding.UTF8; + mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; + mail.IsBodyHtml = true; + client.Send(mail); + + someFiles[counter] = line + "; Processed"; + richTextBox2.AppendText(someFiles[counter] + Environment.NewLine); + } + else + { + richTextBox2.AppendText("list finished!!" + Environment.NewLine); + StringBuilder sb = new StringBuilder(); + foreach (var l in someFiles) + { + sb.AppendLine(l); + + } + File.AppendAllText( "log.txt", sb.ToString()); + Environment.Exit(0); + } + } + catch (Exception ex) + { + richTextBox2.AppendText(ex.ToString() + Environment.NewLine); + someFiles[counter] = line + "; Processed->error"; + + } + + } + + private void richTextBox1_TextChanged(object sender, EventArgs e) + { + + + } + } +} diff --git a/Form1.resx b/Form1.resx new file mode 100644 index 0000000..aac33d5 --- /dev/null +++ b/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/MailSender.csproj b/MailSender.csproj new file mode 100644 index 0000000..af8078f --- /dev/null +++ b/MailSender.csproj @@ -0,0 +1,90 @@ + + + + + Debug + AnyCPU + {F85C7F2C-C86F-4D20-B6D2-56537975EDE4} + WinExe + Properties + MailSender + MailSender + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + \ No newline at end of file diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..31d8d11 --- /dev/null +++ b/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace MailSender +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +}