Advertisement
Guest User

Untitled

a guest
Feb 10th, 2017
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. using System;
  2. using System.Net;
  3. using System.Net.Mail;
  4. using System.IO;
  5.  
  6. namespace espaceNetSAV.Admin
  7. {
  8. class EmailNotification
  9. {
  10. MailAddress from = new MailAddress("mohamedbaza16@gmail.com", "Mohammed BAZA");
  11. MailAddress to = new MailAddress("kingofmad16@gmail.com", "Salah BAZA");
  12.  
  13.  
  14. public EmailNotification()
  15. {
  16. /*
  17. mail = new MailMessage(SENDER, RECIEVER);
  18. client = new SmtpClient();
  19. client.Port = 25;
  20. client.DeliveryMethod = SmtpDeliveryMethod.Network;
  21. client.UseDefaultCredentials = false;
  22. client.Credentials = new NetworkCredential("mohamedbaza16@gmail.com", FileServices.readFile());
  23. client.EnableSsl = true;
  24. client.Host = "smtp.google.com";
  25. mail.Subject = "this is a test mail";
  26. mail.Body = "this is a test mail body";
  27. client.Send(mail);
  28. */
  29. /* ######## Second Method #########*/
  30.  
  31. SmtpClient client = new SmtpClient
  32. {
  33. Host = "smtp.gmail.com",
  34. Port = 587,
  35. EnableSsl = true,
  36. DeliveryMethod = SmtpDeliveryMethod.Network,
  37. UseDefaultCredentials = false,
  38. Credentials = new NetworkCredential(from.Address, "Bazaking16")
  39. };
  40.  
  41. using (MailMessage message = new MailMessage(from, to) {
  42. Subject = "Subject goes here!",
  43. Body = "Body goes here!"
  44. })
  45. {
  46. client.Send(message);
  47. }
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement