SHARE
TWEET

Untitled

a guest Aug 31st, 2015 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Net;
  2. using System.Net.Mail;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12.  
  13. namespace תוכנה_מצויינת_למיקמק_עובדת
  14. {
  15.     public partial class Form1 : Form
  16.     {
  17.         public Form1()
  18.         {
  19.             InitializeComponent();
  20.         }
  21.  
  22.         private void button1_Click(object sender, EventArgs e)
  23.         {
  24.             using System.Net;
  25.             using System.Net.Mail;
  26.  
  27. class Program
  28.         {
  29.             static void Main()
  30.             {
  31.                 string smtpAddress = "smtp.mail.yahoo.com";
  32.                 int portNumber = 587;
  33.                 bool enableSSL = true;
  34.  
  35.                 string emailFrom = "oded4664@gmail.com";
  36.                 string password = "*******";
  37.                 string emailTo = "oded4664@gmail.com";
  38.                 string subject = "Hello";
  39.                 string body = "Hello, I'm just writing this to say Hi!";
  40.  
  41.                 using (MailMessage mail = new MailMessage())
  42.                 {
  43.                     mail.From = new MailAddress(emailFrom);
  44.                     mail.To.Add(emailTo);
  45.                     mail.Subject = subject;
  46.                     mail.Body = body;
  47.                     mail.IsBodyHtml = true;
  48.                     // Can set to false, if you are sending pure text.
  49.  
  50.                     mail.Attachments.Add(new Attachment("C:\\SomeFile.txt"));
  51.                     mail.Attachments.Add(new Attachment("C:\\SomeZip.zip"));
  52.  
  53.                     using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
  54.                     {
  55.                         smtp.Credentials = new NetworkCredential(emailFrom, password);
  56.                         smtp.EnableSsl = enableSSL;
  57.                         smtp.Send(mail);
  58.                     }
  59.                 }
  60.             }
  61.         }
  62.     }
  63.     }
  64. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top