Send inputfield entries via email

So I recently obtained a code from How To send Email with C# on Unity 3D 4.1.2? - Unity Answers

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");
         
         }
 }

I haven’t been using the new UI myself, but couldn’t you just do something like this?

string MailText;

void Update() {
      MailText = UI.Text;
}

void Main() {
     ....
     Mail.Body = MailText;
     .....
}

This should do it:

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
using System.Net;
using System.Net.Mail;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;

[RequireComponent(typeof(InputField))]
public class SendMail : MonoBehaviour {

	InputField inpfield;

	void Start() {
		inpfield = GetComponent<InputField> ();
	}

	void Update() {
		if (Input.GetButtonDown ("Jump")) {
			SendTheMail(inpfield.text);
		}
	}

	void SendTheMail(string text) {
		MailMessage mail = new MailMessage();
		
		mail.From = new MailAddress("youraddress@gmail.com");
		mail.To.Add("youraddress@gmail.com");
		mail.Subject = "Test Mail";
		mail.Body = text;
		
		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");
	}
}