diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.csproj b/IRaCIS.Core.API/IRaCIS.Core.API.csproj index 3554a605a..61a21c492 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.csproj +++ b/IRaCIS.Core.API/IRaCIS.Core.API.csproj @@ -112,6 +112,9 @@ Always + + Always + Always diff --git a/IRaCIS.Core.API/wwwroot/EmailTemplate/UserOptCommon.html b/IRaCIS.Core.API/wwwroot/EmailTemplate/UserOptCommon.html new file mode 100644 index 000000000..90dbb7d41 --- /dev/null +++ b/IRaCIS.Core.API/wwwroot/EmailTemplate/UserOptCommon.html @@ -0,0 +1,27 @@ + + + + + Title + + +
+
+
+ {0}您好: +
+
+ 感谢您使用展影云平台。 +
+
+ {1},验证码是: {2},请在3分钟内输入该验证码,进行后续操作。如非本人操作,请忽略该邮件。 +
+ +
+
祝您顺利!/Best Regards
+
上海展影医疗科技有限公司
+
+
+
+ + diff --git a/IRaCIS.Core.Application/Service/Common/MailService.cs b/IRaCIS.Core.Application/Service/Common/MailService.cs index 2aa8d41ca..4551636fe 100644 --- a/IRaCIS.Core.Application/Service/Common/MailService.cs +++ b/IRaCIS.Core.Application/Service/Common/MailService.cs @@ -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 _systemBasicDatarepository; + private readonly IWebHostEnvironment _hostEnvironment; - public MailVerificationService(IRepository verificationCodeRepository, IRepository systemBasicDatarepository) + + public MailVerificationService(IRepository verificationCodeRepository, IRepository systemBasicDatarepository , IWebHostEnvironment hostEnvironment) { _verificationCodeRepository = verificationCodeRepository; _systemBasicDatarepository = systemBasicDatarepository; + _hostEnvironment = hostEnvironment; + } //重置邮箱 @@ -48,31 +53,24 @@ namespace IRaCIS.Application.Services var builder = new BodyBuilder(); - builder.HtmlBody = @$" -
-
-
- 尊敬的{userName}, 您好: -
-
- 感谢您使用展影云平台。 -
-
- 您正在进行邮箱重置操作,验证码是: {verificationCode},请在3分钟内输入该验证码,进行后续操作。如非本人操作,请忽略该邮件。 -
-
- 此邮件属系统自动发出,无需回复。 -
-
- 祝您顺利!/Best Regards。 -
-
- 上海展影医疗科技有限公司 -
-
-
- "; + 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 = @$" -
-
-
- 您好: -
-
- 感谢您使用展影云平台。 -
-
- 您正在进行邮箱重置密码操作,验证码是: {verificationCode},请在3分钟内输入该验证码,进行后续操作。如非本人操作,请忽略该邮件。 -
-
- 此邮件属系统自动发出,无需回复。 -
-
- 祝您顺利!/Best Regards。 -
-
- 上海展影医疗科技有限公司 -
-
-
- "; + 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 = @$" -
-
-
- 您好: -
-
- 感谢您使用展影云平台。 -
-
- 您正在参与展影医疗IRC项目中心调研工作,验证码是: {verificationCode},请在3分钟内输入该验证码,进行后续操作。如非本人操作,请忽略该邮件。 -
-
- 此邮件属系统自动发出,无需回复。 -
-
- 祝您顺利!/Best Regards。 -
-
- 上海展影医疗科技有限公司 -
-
-
- "; + 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();