Advertisement
Guest User

Untitled

a guest
Mar 1st, 2017
680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. public void EnvoyerMail ()
  2. {
  3. MailMessage mail = new MailMessage();
  4.  
  5. mail.From = new MailAddress("xxxx@gmail.com");
  6. mail.To.Add("xxxx@gmail.com");
  7. mail.Subject = "Test Mail";
  8. mail.Body = "This is for testing SMTP mail from GMAIL";
  9.  
  10. SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
  11. smtpServer.Port = 587;
  12. smtpServer.Credentials = new System.Net.NetworkCredential("xxxx@gmail.com", "password") as ICredentialsByHost;
  13. smtpServer.EnableSsl = true;
  14. ServicePointManager.ServerCertificateValidationCallback =
  15. delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
  16. { return true; };
  17. smtpServer.Send(mail);
  18. Debug.Log("success");
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement