Stop Game Pausing while Sending Email

Hi All,
I am trying to send an email with a small attachment (12 kb).
When doing so, the game pauses briefly while sending the message.
Is there any way to avoid this pause?
Thanks,
Roger

public static function SendEmail(){

	//if (System.IO.File.Exists(logfile)){

	   try{

	   var emailtouse = "myemailaddress@gmail.com";
	   var sender: Object;
	   var certificate: System.Security.Cryptography.X509Certificates.X509Certificate;
	   var chain: System.Security.Cryptography.X509Certificates.X509Chain;
	   var sslPolicyErrors: System.Net.Security.SslPolicyErrors;

		var mail: MailMessage  = new MailMessage();
		mail.From = new MailAddress(emailtouse);
		mail.To.Add(emailtouse);
		mail.Subject = "Test Mail";
		mail.Body = "This is for testing SMTP mail from GMAIL using JAVA";
		
		var attachmentPath = Application.persistentDataPath + "/logtext.txt";
		//Debug.Log("filenamesent"+filename);
		var attachment: System.Net.Mail.Attachment  = new System.Net.Mail.Attachment(attachmentPath);
		mail.Attachments.Add(attachment);
		
		var smtpServer: SmtpClient = new SmtpClient("smtp.gmail.com");
		smtpServer.Port = 587;
		smtpServer.Credentials = new System.Net.NetworkCredential(emailtouse, "mysecretpassword") as ICredentialsByHost;
		smtpServer.EnableSsl = true;
		ServicePointManager.ServerCertificateValidationCallback = function(sender, certificate, chain, sslPolicyErrors) { return true; };
			
		smtpServer.Send(mail);
		Debug.Log("success");
		}
		
		catch (err) {
		    print (err.Message);
		}
	//}
	
}

If you call a blocking operation on the main thread, Unity must wait until that operation is complete.

Generally speaking, you’ll either have to use a coroutine or find some way to make your call asynchronous. There are plenty of other pages which discuss these topics, but that’s what you’ll need to look into.

@rogiedodgie38, The solution es change the line:

smtpServer.Send(mail);

to

smtpServer.SendAsync (mail, "Some text here");