Advertisement
0FFSH0R3

Mailer

Nov 12th, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.06 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.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11. using Ionic.Zip;
  12. using System.Net.Mail;
  13. using System.Net;
  14.  
  15. namespace Mailer
  16. {
  17.     public partial class Form1 : Form
  18.     {
  19.         public Form1()
  20.         {
  21.             InitializeComponent();
  22.         }
  23.    
  24.         private void zip()
  25.         {
  26.  
  27.             ZipFile zip = new ZipFile();
  28.                 {
  29.                     String[] filenames = System.IO.Directory.GetFileSystemEntries(Directory.GetCurrentDirectory());
  30.                     progressBar1.Maximum = filenames.Length-2;
  31.                
  32.                     foreach (String filename in filenames)
  33.                     {
  34.  
  35.  
  36.                        
  37.  
  38.                         if (filename.Contains("Mailer") || (filename.Contains("Ionic")))
  39.                             continue;
  40.                         progressBar1.Value++;
  41.                         progressBar1.Update();
  42.  
  43.                         listBox1.Items.Add(filename.ToString());
  44.                         ZipEntry e= zip.AddFile(filename,"");
  45.                     }
  46.  
  47.                     zip.Save("Mailer.zip");
  48.                 }
  49.         }
  50.         private void send()
  51.         {
  52.          
  53.                 MailMessage message = new MailMessage("ecexxxx@upnet.gr","paraliptis@something.com");
  54.                 Attachment data = new Attachment("Mailer.zip");
  55.                 message.Attachments.Add(data);
  56.                 SmtpClient client = new SmtpClient("patreas.upatras.gr");
  57.                 client.Credentials = CredentialCache.DefaultNetworkCredentials;
  58.                
  59.                 client.Send(message);
  60.  
  61.                
  62.         }
  63.         private void button1_Click(object sender, EventArgs e)
  64.         {
  65.             listBox1.Items.Clear();
  66.             progressBar1.Value = 0;
  67.             zip();
  68.             send();
  69.             MessageBox.Show("Message Sent Succesfully");
  70.         }
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement