邮件发送模板

Uat_Study
hang 2022-05-20 14:40:24 +08:00
parent 2fc4bbc5c1
commit c938a9c27e
3 changed files with 87 additions and 73 deletions

View File

@ -112,6 +112,9 @@
<Content Update="wwwroot\EmailTemplate\TrialUserExistJoin.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\EmailTemplate\UserOptCommon.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\EmailTemplate\TrialUserFirstJoin.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<title>Title</title>
</head>
<body style='font-family: 微软雅黑;padding: 0;margin: 0;'>
<div style='padding-left: 40px;background: #f6f6f6'>
<div style='padding-top: 20px;'>
<div style='line-height: 40px;font-size: 18px'>
{0}您好:
</div>
<div style='line-height: 40px;padding-left: 40px;margin-bottom: 10px;'>
感谢您使用展影云平台。
</div>
<div style='line-height: 40px;padding-left: 40px;margin-bottom: 10px;'>
{1},验证码是: {2}请在3分钟内输入该验证码进行后续操作。如非本人操作请忽略该邮件。
</div>
<div style='line-height: 24px;font-size: 14px;color:#333;margin-top: 20px;padding-bottom: 40px;'>
<div>祝您顺利!/Best Regards</div>
<div style="font-size: 14px;">上海展影医疗科技有限公司</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -5,6 +5,7 @@ using MailKit.Security;
using MimeKit;
using IRaCIS.Core.Application.Helper;
using MailKit;
using Microsoft.AspNetCore.Hosting;
namespace IRaCIS.Application.Services
{
@ -25,12 +26,16 @@ namespace IRaCIS.Application.Services
private readonly IRepository<SystemBasicData> _systemBasicDatarepository;
private readonly IWebHostEnvironment _hostEnvironment;
public MailVerificationService(IRepository<VerificationCode> verificationCodeRepository, IRepository<SystemBasicData> systemBasicDatarepository)
public MailVerificationService(IRepository<VerificationCode> verificationCodeRepository, IRepository<SystemBasicData> systemBasicDatarepository , IWebHostEnvironment hostEnvironment)
{
_verificationCodeRepository = verificationCodeRepository;
_systemBasicDatarepository = systemBasicDatarepository;
_hostEnvironment = hostEnvironment;
}
//重置邮箱
@ -48,31 +53,24 @@ namespace IRaCIS.Application.Services
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'>
{userName},
</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>";
var pathToFile = _hostEnvironment.WebRootPath
+ Path.DirectorySeparatorChar.ToString()
+ "EmailTemplate"
+ Path.DirectorySeparatorChar.ToString()
+ "UserOptCommon.html";
using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
{
var templateInfo = SourceReader.ReadToEnd();
builder.HtmlBody = string.Format(templateInfo,
$" 尊敬的 {userName} , ",
"您正在进行邮箱重置操作",
verificationCode
);
}
messageToSend.Body = builder.ToMessageBody();
@ -115,30 +113,24 @@ namespace IRaCIS.Application.Services
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>";
var pathToFile = _hostEnvironment.WebRootPath
+ Path.DirectorySeparatorChar.ToString()
+ "EmailTemplate"
+ Path.DirectorySeparatorChar.ToString()
+ "UserOptCommon.html";
using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
{
var templateInfo = SourceReader.ReadToEnd();
builder.HtmlBody = string.Format(templateInfo,
"",
"您正在进行邮箱重置密码操作",
verificationCode
);
}
messageToSend.Body = builder.ToMessageBody();
@ -182,31 +174,23 @@ namespace IRaCIS.Application.Services
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>
IRC: {verificationCode}3
</div>
<div>
</div>
<div>
/Best Regards
</div>
<div>
</div>
</div>
</div>
</body>";
var pathToFile = _hostEnvironment.WebRootPath
+ Path.DirectorySeparatorChar.ToString()
+ "EmailTemplate"
+ Path.DirectorySeparatorChar.ToString()
+ "UserOptCommon.html";
using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
{
var templateInfo = SourceReader.ReadToEnd();
builder.HtmlBody = string.Format(templateInfo,
"",
"您正在参与展影医疗IRC项目中心调研工作",
verificationCode
);
}
messageToSend.Body = builder.ToMessageBody();