修改邮件发送

This commit is contained in:
2022-05-30 09:00:44 +08:00
parent a1e06f6536
commit d3af4696c2
7 changed files with 10 additions and 132 deletions
@@ -11,7 +11,6 @@ namespace IRaCIS.Application.Services
{
public interface IMailVerificationService
{
Task SendMail(Guid userId, string userName, string emailAddress, int verificationCode);
Task AnolymousSendEmail(string researchProgramNo, string emailAddress, int verificationCode);
@@ -458,72 +457,6 @@ namespace IRaCIS.Application.Services
//废弃 添加用户发送邮件
public async Task SendMail(Guid userId, string userName, string emailAddress, int verificationCode)
{
var messageToSend = new MimeMessage();
//发件地址
messageToSend.From.Add(new MailboxAddress("GRR", "iracis_grr@163.com"));
//收件地址
messageToSend.To.Add(new MailboxAddress(userName, emailAddress));
//主题
messageToSend.Subject = "[来自展影IRC] 关于重置邮箱的提醒";
var builder = new BodyBuilder();
builder.HtmlBody = @$"<body style='font-family: 微软雅黑;padding: 0;margin: 0;'>
<div style='padding-left: 40px;background: #f6f6f6'>
<div style='padding-top: 20px;padding-bottom:40px'>
<div style='line-height: 40px;font-size: 18px'>
您好:
</div>
<div style='line-height: 40px;padding-left: 40px;margin-bottom: 10px;'>
感谢您使用展影云平台。
</div>
<div>
您正在进行邮箱重置操作,验证码是: {verificationCode},请在3分钟内输入该验证码,进行后续操作。如非本人操作,请忽略该邮件。
</div>
<div>
此邮件属系统自动发出,无需回复。
</div>
<div>
祝您顺利!/Best Regards。
</div>
<div>
上海展影医疗科技有限公司
</div>
</div>
</div>
</body>";
messageToSend.Body = builder.ToMessageBody();
EventHandler<MessageSentEventArgs> sucessHandle = (sender, args) =>
{
// args.Response
var code = verificationCode.ToString();
_ = _verificationCodeRepository.AddAsync(new VerificationCode()
{
CodeType = 0,
HasSend = true,
Code = code,
UserId = userId,
ExpirationTime = DateTime.Now.AddMinutes(3)
}).Result;
_ = _verificationCodeRepository.SaveChangesAsync().Result;
};
await SendEmailHelper.SendEmailAsync(messageToSend, sucessHandle);
}
}
}