SHARE
TWEET

Untitled

a guest Aug 31st, 2015 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         using System.Net ;
  2. using System.Net.Mail;
  3.  
  4. string smtpAddress = "smtp.mail.yahoo.com";
  5. int portNumber = 587;
  6. bool enableSSL = true;
  7.  
  8. string emailFrom = "oded4664@gmail.com";
  9. string password = "*******";
  10. string emailTo = "oded4664@gmail.com";
  11. string subject = "Hello";
  12. string body = "Hello, I'm just writing this to say Hi!";
  13.  
  14. using (MailMessage mail = new MailMessage())
  15. {
  16.     mail.From = new MailAddress(emailFrom);
  17.     mail.To.Add(emailTo);
  18.     mail.Subject = subject;
  19.     mail.Body = body;
  20.     mail.IsBodyHtml = true;
  21.     // Can set to false, if you are sending pure text.
  22.  
  23.     mail.Attachments.Add(new Attachment("C:\\SomeFile.txt"));
  24.     mail.Attachments.Add(new Attachment("C:\\SomeZip.zip"));
  25.  
  26.     using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
  27.     {
  28.         smtp.Credentials = new NetworkCredential(emailFrom, password);
  29.         smtp.EnableSsl = enableSSL;
  30.         smtp.Send(mail);
  31.     }
  32. }
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