Sure, you should be able to use this code. Just create a file called SendEmail.cs and place it in your /Scripts folder. This assumes you are joker@gmail.com (password = justjokering) and sending the email to yourself. You can call it from another file, perhaps where you have the score variable computed using:
SendEmail.SendResults("joker@gmail.com","emailBodyText","emailSubjectText");
Here is the contents of the SendEmail.cs file:
using System.Net;
using System.Net.Mail;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using UnityEngine;
using System.IO;
using UnityEngine.UI;
using System;
using System.Collections.Generic;
public class SendEmail : MonoBehaviour
{
public string subject = "New Score Acquired";
public string body = "putyourscoreASASTRINGhere";
public string password = "";
public void SendResults(string toAddress, string bodyText, string subjectText)
{
WriteDataFile(subjectText, bodyText);
MailMessage mail = new MailMessage();
mail.From = new MailAddress("joker@gmail.com");
mail.To.Add(toAddress);
mail.Subject = subjectText;
mail.Body = bodyText;
//var fileToAttach = GetComponent<realPicVerifApp>().logFilePathLocal;
//mail.Attachments.Add(new Attachment(sshotlocation));
SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
smtpServer.Port = 587;
smtpServer.Credentials = new System.Net.NetworkCredential("joker@gmail.com", "justjokering") as ICredentialsByHost;
smtpServer.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback =
delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{ return true; };
smtpServer.Send(mail);
Debug.Log("success");
}
}