0
MailKit
ライブラリjstedfastを使用してxamarin.androidアプリからメールを送信できません。xamarin.androidアプリからMailkitを使用してメールを送信できません
私は次のコードを使用しています:私は私のアプリから、このコードを実行すると、それが例外をスロー
try
{
//From Address
string FromAddress = "[email protected]";
string FromAdressTitle = "Email Title";
//To Address
string ToAddress = "[email protected]";
string ToAdressTitle = "Address Title";
string Subject = "Subject of mail";
string BodyContent = "Body of email";
//Smtp Server
string SmtpServer = "smtp.gmail.com";
//Smtp Port Number
int SmtpPortNumber = 587;
var mimeMessage = new MimeMessage();
mimeMessage.From.Add(new MailboxAddress(FromAdressTitle, FromAddress));
mimeMessage.To.Add(new MailboxAddress(ToAdressTitle, ToAddress));
mimeMessage.Subject = Subject;
mimeMessage.Body = new TextPart("plain")
{
Text = BodyContent
};
using (var client = new SmtpClient())
{
client.Connect(SmtpServer, SmtpPortNumber, false);
// Note: only needed if the SMTP server requires authentication
// Error 5.5.1 Authentication
client.AuthenticationMechanisms.Remove("XOAUTH2");
client.Authenticate("[email protected]", "password");
client.Send(mimeMessage);
Console.WriteLine("The mail has been sent successfully !!");
Console.ReadLine();
client.Disconnect(true);
}
}
catch (Exception ex)
{
string message = ex.Message;
}
を:
MailKit.Security.AuthenticationException
私が欠けているものこのコード。誰も私を助けることができます!
私はそれが例外をスローして、これを試みた:「{System.Net.Mail.SmtpException:534-5.7.14
あなたのGmailアカウントにアクセスするには、安全性の低いアプリを許可する必要があります。 https://support.google.com/accounts/answer/6010255?hl=ja –
ありがとうございました。アクセスを許可した後は助かりました。 –