Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Net.Mail;
- using System.Net;
- using System.IO;
- namespace WindowsFormsApplication2
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- int help = 0;
- string line;
- string line1;
- string line2;
- string line3;
- string line4;
- int counter = 0;
- int a = 0;
- private void button1_Click(object sender, EventArgs e)
- {
- try
- {
- string help = " are you sure you want to send ";
- help += textBox1.Text;
- help += " E-mails?";
- DialogResult dialogResult = MessageBox.Show(help, "Expected error", MessageBoxButtons.YesNo);
- if (dialogResult == DialogResult.No)
- {
- System.Environment.Exit(0);
- }
- MailMessage message = new MailMessage();
- message.IsBodyHtml = true;
- SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
- smtp.EnableSsl = true;
- NetworkCredential netCre = new NetworkCredential("chenkadosh15@gmail.com", "chenkadosh1");
- smtp.Credentials = netCre;
- bool PassportNumberExistanse = false;
- string[] FullNames = new string[254];
- string[] Email = new string[254];
- string[] PassportNumber = new string[254];
- StreamReader EmailReader = new StreamReader(@"C:\Users\unicorn\Desktop\MyFiles\Emails.txt");
- StreamReader PassportNumberReader = new StreamReader(@"C:\Users\unicorn\Desktop\MyFiles\PassportNumber.txt");
- StreamReader FullNameReader = new StreamReader(@"C:\Users\unicorn\Desktop\MyFiles\Fullnames.txt");
- while ((line = EmailReader.ReadLine()) != null && a < Email.Length)
- {
- Email[a] = line;
- a++;
- }
- a = 0;
- while ((line2 = PassportNumberReader.ReadLine()) != null && a < Email.Length)
- {
- PassportNumber[a] = line2;
- a++;
- }
- for (int i = 0; i <= Email.Length; i++)
- {
- if (PassportNumber[i] == null)
- {
- PassportNumberExistanse = true;
- }
- if (PassportNumberExistanse)
- {
- message.From = new MailAddress(
- "liad.yogev.ly@gmail.com"
- );
- message.To.Add(new MailAddress(Email[i]));
- message.Subject = "Dear ";
- message.Subject += FullNames[i];
- message.Body = FullNames[i];
- message.Body += ", Please provide us your passport Number";
- smtp.Send(message);
- }
- }
- }
- catch
- {
- MessageBox.Show(" Unexpected error reached by the system");
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- button1.Enabled = true;
- string[] FullNames = new string[254];
- string[] Email = new string[254];
- string[] PassportNumber = new string[254];
- StreamReader EmailReader = new StreamReader(@"C:\Users\unicorn\Desktop\MyFiles\Emails.txt");
- StreamReader FullNameReader = new StreamReader(@"C:\Users\unicorn\Desktop\MyFiles\Fullnames.txt");
- StreamReader PassportNumberReader = new StreamReader(@"C:\Users\unicorn\Desktop\MyFiles\PassportNumber.txt");
- int counter = 0;
- while ((line2 = PassportNumberReader.ReadLine()) != null && a < Email.Length)
- {
- PassportNumber[a] = line2;
- a++;
- }
- a = 0;
- while ((line3 = EmailReader.ReadLine()) != null && a < Email.Length)
- {
- Email[a] = line3;
- if (Email[a]=="none@hp.com")
- {
- help++;
- }
- a++;
- }
- for (int i = 0; i <= 253; i++)
- {
- if (PassportNumber[i] == null)
- {
- counter++;
- }
- }
- counter = counter - help;
- textBox1.Text = counter.ToString();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement