Im 스크린 샷을 찍어 저장하고 있지만 읽는 법을 모르며 Gmail로 이메일에 첨부하여 보내주십시오. 지금까지 내가, 당신이 이미 첨부 파일을 추가 할 볼 수스크린 샷을 이메일 첨부 파일로 보내십시오.
// We should only read the screen after all rendering is complete
yield return new WaitForEndOfFrame();
// Create a texture the size of the screen, RGB24 format
int width = Screen.width;
int height = Screen.height;
Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false);
// Read screen contents into the texture
tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
tex.Apply();
// Encode texture into PNG
byte[] bytes = tex.EncodeToPNG();
// save our test image (could also upload to WWW)
File.WriteAllBytes(Application.dataPath + "/../test-" + count + ".png", bytes);
count++;
DestroyObject(tex);
Debug.Log(Application.dataPath + "/../test-" + count + ".png");
MailMessage mail = new MailMessage();
mail.From = new MailAddress("[email protected]");
mail.To.Add("[email protected]");
mail.Subject = "Test";
mail.Body = "testing class";
mail.Attachments.Add(new Attachment(Application.dataPath + "/../teste-" + count + ".png",
Application.dataPath + "/../teste-" + count + ".png",
"png"));
SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
smtpServer.Port = 587;
smtpServer.Credentials = new System.Net.NetworkCredential("[email protected]", "123456") as ICredentialsByHost;
smtpServer.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback =
delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
};
smtpServer.Send(mail);
Debug.Log("success");
내가 볼 수있는 유일한 방법은 당신의'MailMessage'와'SmtpClient' 객체가 제대로 닫히지 확인하기 위해,'using' 블록의 내부에 있어야한다. 나는'using' 블록이 추가 될 때까지 이메일 전송이 지연되는 문제로 과거에 문제가있었습니다. –