Take Gmail for example.
Tap the Capture button on the screen to get the current screen, and click the Send button to send the previous message as an attachment.
usingUnityengine;usingSystem.Collections;usingSystem;usingSystem.Net;usingSystem.Net.Mail;usingSystem.Net.Security;usingSystem.Security.Cryptography.X509Certificates; Public classTrydemo:monobehaviour {//Use this for initialization voidStart () {}//Update is called once per frame voidUpdate () {}voidOngui () {if(GUI. Button (NewRect (0, -, -, +),"Capture") {Debug.Log ("Capture screenshot"); Application.capturescreenshot ("Screen.png"); } if(GUI. Button (NewRect (0,0, -, +),"Send") ) {SendEmail (); } } Private voidSendEmail () {MailMessage mail=NewMailMessage (); Mail. from=NewMailAddress ("[email protected]"); Mail. To.add ("[email protected]"); Mail. Subject="Test Mail"; Mail. Body="testing SMTP mail from GMAIL"; Mail. Attachments.Add (NewAttachment ("Screen.png")); SmtpClient SmtpServer=NewSmtpClient ("smtp.gmail.com"); Smtpserver.port=587; Smtpserver.credentials=NewSystem.Net.NetworkCredential ("[email protected]","YourPassword") asIcredentialsbyhost; Smtpserver.enablessl=true; Servicepointmanager.servercertificatevalidationcallback=Delegate(Objects, x509certificate certificate, X509chain chain, sslpolicyerrors sslpolicyerrors) { return true; }; Smtpserver.send (mail); Debug.Log ("Success"); }}
①application.registerlogcallback (Ondebugcallbackhandler); You can add a callback function to debug print, listen for each print, and use this to determine if there is an error log and react.
② Basic Send Error log method is sent by mail, you can use C # script in unity to send mail, the specific method mentioned above, or through Process.Start ("Name.exe") to invoke external programs to send log mail, Specific operation can be Baidu C program to send mail, there are many examples.
③ sending mail logs in C # scripts is easier to implement, and C # provides the encapsulation of mail-sending capabilities. You can also use Application.capturescreenshot ("filename") to save the program for sending, providing errors.
Original link
How to use Unity3d to send messages with attachments