Guest User

Untitled

a guest
Oct 22nd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. using System.Net;
  2. using System.Net.Mail;
  3.  
  4. public static class EmailHandler
  5. {
  6. public static void SendEmail
  7. (
  8. string from ,
  9. string password ,
  10. string to ,
  11. string subject ,
  12. string body
  13. )
  14. {
  15. var message = new MailMessage
  16. (
  17. from : from,
  18. to : to,
  19. subject : subject,
  20. body : body
  21. );
  22.  
  23. var smtp = new SmtpClient
  24. {
  25. Host = "smtp.gmail.com",
  26. Port = 587,
  27. Credentials = new NetworkCredential( from, password ) as ICredentialsByHost,
  28. EnableSsl = true,
  29. };
  30.  
  31. ServicePointManager.ServerCertificateValidationCallback =
  32. ( sender, certificate, chain, sslPolicyErrors ) => true;
  33.  
  34. smtp.Send( message );
  35. }
  36. }
Add Comment
Please, Sign In to add comment