Advertisement
Guest User

Untitled

a guest
Jul 20th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Net.Mail;
  10. using System.Net;
  11. using System.IO;
  12.  
  13.  
  14.  
  15. namespace WindowsFormsApplication2
  16. {
  17.     public partial class Form1 : Form
  18.     {
  19.         public Form1()
  20.         {
  21.             InitializeComponent();
  22.         }
  23.         int help = 0;
  24.         string line;
  25.         string line1;
  26.         string line2;
  27.         string line3;
  28.         string line4;
  29.         int counter = 0;
  30.  
  31.  
  32.         int a = 0;
  33.  
  34.  
  35.         private void button1_Click(object sender, EventArgs e)
  36.         {
  37.            
  38.             try
  39.             {
  40.                 string help = " are you sure you want to send ";
  41.                 help += textBox1.Text;
  42.                 help += "  E-mails?";
  43.  
  44.                 DialogResult dialogResult = MessageBox.Show(help, "Expected error", MessageBoxButtons.YesNo);
  45.              
  46.                  if (dialogResult == DialogResult.No)
  47.                 {
  48.                     System.Environment.Exit(0);
  49.  
  50.                 }
  51.  
  52.  
  53.  
  54.                 MailMessage message = new MailMessage();
  55.  
  56.  
  57.  
  58.  
  59.  
  60.                 message.IsBodyHtml = true;
  61.  
  62.  
  63.                 SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
  64.                 smtp.EnableSsl = true;
  65.                 NetworkCredential netCre = new NetworkCredential("chenkadosh15@gmail.com", "chenkadosh1");
  66.                 smtp.Credentials = netCre;
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.                 bool PassportNumberExistanse = false;
  74.  
  75.  
  76.                 string[] FullNames = new string[254];
  77.  
  78.                 string[] Email = new string[254];
  79.                 string[] PassportNumber = new string[254];
  80.  
  81.                 StreamReader EmailReader = new StreamReader(@"C:\Users\unicorn\Desktop\MyFiles\Emails.txt");
  82.                 StreamReader PassportNumberReader = new StreamReader(@"C:\Users\unicorn\Desktop\MyFiles\PassportNumber.txt");
  83.  
  84.                 StreamReader FullNameReader = new StreamReader(@"C:\Users\unicorn\Desktop\MyFiles\Fullnames.txt");
  85.  
  86.  
  87.  
  88.  
  89.              
  90.  
  91.  
  92.  
  93.  
  94.  
  95.                 while ((line = EmailReader.ReadLine()) != null && a < Email.Length)
  96.                 {
  97.                     Email[a] = line;
  98.                     a++;
  99.  
  100.                 }
  101.                 a = 0;
  102.  
  103.  
  104.                 while ((line2 = PassportNumberReader.ReadLine()) != null && a < Email.Length)
  105.                 {
  106.                     PassportNumber[a] = line2;
  107.                     a++;
  108.  
  109.                 }
  110.  
  111.  
  112.  
  113.  
  114.                 for (int i = 0; i <= Email.Length; i++)
  115.                 {
  116.                     if (PassportNumber[i] == null)
  117.                     {
  118.                         PassportNumberExistanse = true;
  119.                     }
  120.  
  121.                     if (PassportNumberExistanse)
  122.                     {
  123.                         message.From = new MailAddress(
  124.                     "liad.yogev.ly@gmail.com"
  125.                   );
  126.                        
  127.                         message.To.Add(new MailAddress(Email[i]));
  128.  
  129.                         message.Subject = "Dear ";
  130.  
  131.                         message.Subject += FullNames[i];
  132.  
  133.                         message.Body = FullNames[i];
  134.  
  135.  
  136.                         message.Body += ", Please provide us your passport Number";
  137.  
  138.                         smtp.Send(message);
  139.  
  140.  
  141.                     }
  142.  
  143.  
  144.  
  145.                 }
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.             }
  154.  
  155.             catch
  156.             {
  157.                 MessageBox.Show(" Unexpected error reached by the system");
  158.  
  159.  
  160.             }
  161.  
  162.  
  163.  
  164.  
  165.         }
  166.  
  167.         private void button2_Click(object sender, EventArgs e)
  168.         {
  169.             button1.Enabled = true;
  170.  
  171.  
  172.             string[] FullNames = new string[254];
  173.  
  174.             string[] Email = new string[254];
  175.             string[] PassportNumber = new string[254];
  176.  
  177.             StreamReader EmailReader = new StreamReader(@"C:\Users\unicorn\Desktop\MyFiles\Emails.txt");
  178.            
  179.  
  180.             StreamReader FullNameReader = new StreamReader(@"C:\Users\unicorn\Desktop\MyFiles\Fullnames.txt");
  181.  
  182.             StreamReader PassportNumberReader = new StreamReader(@"C:\Users\unicorn\Desktop\MyFiles\PassportNumber.txt");
  183.  
  184.  
  185.             int counter = 0;
  186.  
  187.             while ((line2 = PassportNumberReader.ReadLine()) != null && a < Email.Length)
  188.             {
  189.                 PassportNumber[a] = line2;
  190.                 a++;
  191.  
  192.             }
  193.             a = 0;
  194.  
  195.             while ((line3 = EmailReader.ReadLine()) != null && a < Email.Length)
  196.             {
  197.                 Email[a] = line3;
  198.  
  199.                
  200.  
  201.  
  202.                 if (Email[a]=="none@hp.com")
  203.                 {
  204.                     help++;
  205.                    
  206.  
  207.                    
  208.                 }
  209.                 a++;
  210.  
  211.                
  212.  
  213.  
  214.             }
  215.  
  216.            
  217.  
  218.  
  219.            
  220.  
  221.             for (int i = 0; i <= 253; i++)
  222.             {
  223.                 if (PassportNumber[i] == null)
  224.                 {
  225.                     counter++;
  226.                    
  227.  
  228.  
  229.                 }
  230.  
  231.             }
  232.  
  233.  
  234.            
  235.  
  236.             counter = counter - help;
  237.  
  238.  
  239.             textBox1.Text = counter.ToString();
  240.         }
  241.     }
  242. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement