Skip to content

Commit

Permalink
Update MailSender.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
nikidimitrow authored Dec 6, 2019
1 parent 2be35e9 commit 3866d89
Showing 1 changed file with 5 additions and 28 deletions.
33 changes: 5 additions & 28 deletions MailSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@ public partial class Form1 : Form

public Form1()
{
InitializeComponent();



InitializeComponent();
passwordTextBox.PasswordChar = '*';
}

private void textBox1_TextChanged(object sender, EventArgs e)
{

}

public void textBox2_MouseClick(object sender, MouseEventArgs e)
Expand All @@ -52,9 +48,7 @@ private void button1_Click(object sender, EventArgs e)
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);
}

Expand All @@ -74,19 +68,12 @@ private void timer1_Tick(object sender, EventArgs e)
int counter = -1;
int flag = 0;
try {
// timer1.Enabled = false;
string Subject = textBox1.Text;

string Subject = textBox1.Text;
string body;

//var logFile = File.ReadAllLines(textBox2.Text);//eto
//someFiles = new List<string>(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"))
Expand All @@ -95,25 +82,20 @@ private void timer1_Tick(object sender, EventArgs e)
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


// The form is as follow: name, mail, city, 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;
Expand All @@ -126,7 +108,6 @@ private void timer1_Tick(object sender, EventArgs e)
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;
Expand All @@ -143,7 +124,6 @@ private void timer1_Tick(object sender, EventArgs e)
foreach (var l in someFiles)
{
sb.AppendLine(l);

}
File.AppendAllText( "log.txt", sb.ToString());
Environment.Exit(0);
Expand All @@ -153,14 +133,11 @@ private void timer1_Tick(object sender, EventArgs e)
{
richTextBox2.AppendText(ex.ToString() + Environment.NewLine);
someFiles[counter] = line + "; Processed->error";

}

}

private void richTextBox1_TextChanged(object sender, EventArgs e)
{


}
}
Expand Down

0 comments on commit 3866d89

Please sign in to comment.