SHARE
TWEET

Untitled

a guest Aug 31st, 2015 62 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.             string smtpAddress = "smtp.gmail.com";
  28.             int portNumber = 587;
  29.             bool enableSSL = true;
  30.  
  31.             string emailFrom = "oded4664@gmail.com";
  32.             string password = "*******";
  33.             string emailTo = "oded4664@gmail.com";
  34.             string subject = "Hello";
  35.             string body = "Hello, I'm just writing this to say Hi!";
  36.  
  37.             using (MailMessage mail = new MailMessage())
  38.             {
  39.                 mail.From = new MailAddress(emailFrom);
  40.                 mail.To.Add(emailTo);
  41.                 mail.Subject = subject;
  42.                 mail.Body = body;
  43.                 mail.IsBodyHtml = true;
  44.                 // Can set to false, if you are sending pure text.
  45.  
  46.                 //mail.Attachments.Add(new Attachment("C:\\SomeFile.txt"));
  47.                 //mail.Attachments.Add(new Attachment("C:\\SomeZip.zip"));
  48.  
  49.                 using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
  50.                 {
  51.                     smtp.Credentials = new NetworkCredential(emailFrom, password);
  52.                     smtp.EnableSsl = enableSSL;
  53.                     smtp.Send(mail);
  54.                 }
  55.             }
  56.         }
  57.     }
  58. }
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