Код:
Код: Выделить всё
using System;
using System.Collections;
using System.Collections.Generic;
using System.Net.Mail;
using System.Net.Mime;
using System.Text;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.UI;
using System.Threading;
using MimeKit;
using System.IO;
using MailKit.Net.Smtp;
using MailKit.Security;
using TMPro;
namespace SendingEmails
{
public class EmailSenderTEST : MonoBehaviour
{
MailMessage msg;
AlternateView htmlView;
AlternateView plainView;
System.Net.Mail.SmtpClient client;
Thread myThread;
private void Start()
{
myThread = new Thread(SendMsg);
SendMessage();
}
public void SendMessage()
{
string htmlMessage =
@"
";
client = new System.Net.Mail.SmtpClient("smtp-mail.outlook.com", 587);
client.Credentials = new System.Net.NetworkCredential(
SENDER_ADRESS,
SENDER_PASSWORD);
client.EnableSsl = true;
msg = new MailMessage(SENDER_ADRESS,
RECEIVER_ADRESS);
htmlView = AlternateView.CreateAlternateViewFromString(
htmlMessage,
Encoding.UTF8,
MediaTypeNames.Text.Html);
plainView = AlternateView.CreateAlternateViewFromString(
Regex.Replace(htmlMessage,
"]+?>",
string.Empty),
Encoding.UTF8,
MediaTypeNames.Text.Plain);
msg.AlternateViews.Add(plainView);
msg.AlternateViews.Add(htmlView);
msg.IsBodyHtml = true;
msg.Subject = " " + "Some subject, testing";
msg.Body = "Hey this is the email I sent";
myThread.Start();
client.Send(msg);
}
void SendMsg()
{
Debug.Log("Sent");
}
}
}

Я пытался следовать различным инструкциям, касающимся безопасности и сторонних приложений, но ни одно из них не помогло.