So I recently obtained a code from http://answers.unity3d.com/questions/433283/how-to-send-email-with-c.html
This just sends an email. But is it possible to take the text written from a user in an inputfield (unity 5 UI) and slot that in the code below as the message? Help would be greatly appreciated!
using UnityEngine;
using System.Collections;
using System;
using System.Net;
using System.Net.Mail;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public class mono_gmail : MonoBehaviour {
void Main ()
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress("youraddress@gmail.com");
mail.To.Add("youraddress@gmail.com");
mail.Subject = "Test Mail";
mail.Body = "This is for testing SMTP mail from GMAIL";
SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
smtpServer.Port = 587;
smtpServer.Credentials = new System.Net.NetworkCredential("youraddress@gmail.com", "yourpassword") as ICredentialsByHost;
smtpServer.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback =
delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{ return true; };
smtpServer.Send(mail);
Debug.Log("success");
}
}
↧