Advertisement
subzero911

SendMail

Jun 19th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1.     public void SendMail(string subject, string body)
  2.     {
  3.         MailMessage mail = new MailMessage();
  4.  
  5.         mail.From = new MailAddress(mailAddress);
  6.         mail.To.Add(mailAddress);
  7.         mail.Subject = subject;
  8.         mail.Body = body;
  9.  
  10.         SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
  11.         smtpServer.Port = 587;
  12.         smtpServer.Credentials = new NetworkCredential(mailAddress, mailPassword) 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("mail success");
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement