This is my code :
void Mail(){
MailMessage mail = new MailMessage();
mail.From = new MailAddress("aaaaa@gmail.com");
mail.To.Add("bbbb@.com.vn");
mail.Subject = "Hello!!!";
mail.Body = "This is word and image for you.";
string attachmentPath = filename;
Debug.Log(attachmentPath);
Attachment attachmentFile = new Attachment(attachmentPath);
mail.Attachments.Add(attachmentFile);
SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
smtpServer.Port = 587;
#if UNITY_IPHONE
smtpServer.Credentials = new System.Net.NetworkCredential("aaaaaaaa@gmail.com", "xxxxxxxxx") as ICredentialsByHost;
#endif
#if UNITY_EDITOR_WIN
smtpServer.Credentials = new System.Net.NetworkCredential("aaaaaaaa@gmail.com", "xxxxxxxxx") as ICredentialsByHost;
#endif
smtpServer.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback =
delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{ return true; };
smtpServer.Send(mail);
}
- I run on unity3d ==> it is good.
- I build into ios,android ==> install on device ==> run ==> it is error ( i don't see email )
- Why?? and Why??.
↧