修改查询bug

This commit is contained in:
2022-10-20 17:55:58 +08:00
parent 64291078a0
commit b6a3391678
10 changed files with 111 additions and 25 deletions
@@ -30,5 +30,43 @@ public static class SendEmailHelper
}
}
public static async Task SendEmailAsync(MimeMessage messageToSend, SMTPEmailConfig sMTPEmailConfig, EventHandler<MessageSentEventArgs>? messageSentSuccess = null)
{
using (var smtp = new MailKit.Net.Smtp.SmtpClient())
{
if (messageSentSuccess != null)
{
smtp.MessageSent += messageSentSuccess;
}
smtp.ServerCertificateValidationCallback = (s, c, h, e) => true;
await smtp.ConnectAsync(sMTPEmailConfig.Host, sMTPEmailConfig.Port, SecureSocketOptions.SslOnConnect);
await smtp.AuthenticateAsync(sMTPEmailConfig.UserName, sMTPEmailConfig.AuthorizationCode);
await smtp.SendAsync(messageToSend);
await smtp.DisconnectAsync(true);
}
}
}
public class SMTPEmailConfig
{
public int Port { get; set; }
public string Host { get; set; }
public string UserName { get; set; }
public string AuthorizationCode { get; set; }
}