Advertisement
Guest User

Untitled

a guest
Aug 31st, 2015
93
0
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. using System.Net;
  13. using System.Net.Mail;
  14.  
  15. namespace תוכנה_מצויינת_למיקמק_עובדת
  16. {
  17.     public partial class Form1 : Form
  18.     {
  19.         public Form1()
  20.         {
  21.             InitializeComponent();
  22.         }
  23.  
  24.         private void button1_Click(object sender, EventArgs e)
  25.         {
  26.             string smtpAddress = "smtp.gmail.com";
  27.             int portNumber = 587;
  28.             bool enableSSL = true;
  29.  
  30.             string emailFrom = "oded4664@gmail.com";
  31.             string password = "*******";
  32.             string emailTo = "oded4664@gmail.com";
  33.             string subject = "Hello";
  34.             string body = "Hello, I'm just writing this to say Hi!";
  35.  
  36.             using (MailMessage mail = new MailMessage())
  37.             {
  38.                 mail.From = new MailAddress(emailFrom);
  39.                 mail.To.Add(emailTo);
  40.                 mail.Subject = subject;
  41.                 mail.Body = body;
  42.                 mail.IsBodyHtml = true;
  43.                 // Can set to false, if you are sending pure text.
  44.  
  45.                 //mail.Attachments.Add(new Attachment("C:\\SomeFile.txt"));
  46.                 //mail.Attachments.Add(new Attachment("C:\\SomeZip.zip"));
  47.  
  48.                 using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
  49.                 {
  50.                     smtp.Credentials = new NetworkCredential(emailFrom, password);
  51.                     smtp.EnableSsl = enableSSL;
  52.                     smtp.Send(mail);
  53.                 }
  54.             }
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement