0
有什麼不對的代碼 - 我只是想送succesfuld後重定向:MVC網核心1.1.0 Mailkit發送郵件的形式返回一個空白頁
公共異步任務SendEmailAsync(字符串電子郵件,字符串名稱,字符串消息) { var emailMessage = new MimeMessage();
emailMessage.From.Add(new MailboxAddress("PAR OG SINGLER", "[email protected]"));
emailMessage.To.Add(new MailboxAddress("per", Email));
emailMessage.Subject = "Test par og singler";
emailMessage.Body = new TextPart("plain") { Text = Message };
using (var client = new SmtpClient())
{
var credentials = new NetworkCredential
{
UserName = "[email protected]", // replace with valid value
Password = "detteerentest" // replace with valid value
};
//var mytask = Email + "" + Message;
client.LocalDomain = "parogsingler.dk";
await client.ConnectAsync("smtp.gmail.com", 587, SecureSocketOptions.Auto).ConfigureAwait(false);
client.AuthenticationMechanisms.Remove("XOAUTH2");
await client.AuthenticateAsync(credentials);
await client.SendAsync(emailMessage).ConfigureAwait(false);
await client.DisconnectAsync(true).ConfigureAwait(false);
RedirectToAction("Thanks");
}
}
public IActionResult Thanks()
{
return View();
}