@@ -54,7 +54,56 @@ public static class CommonEmailHelper
|
||||
return configInfo;
|
||||
}
|
||||
|
||||
public static async Task<TrialEmailNoticeConfig> GetTrialEmailSubejctAndHtmlInfoAndBuildAsync(TrialEmailNoticeConfig configInfo, EmailBusinessScenario scenario, MimeMessage messageToSend,
|
||||
/// <summary>
|
||||
/// 系统默认邮件 + 项目默认邮件 (不用添加到项目邮件配置中,才发送)
|
||||
/// </summary>
|
||||
/// <param name="configInfo"></param>
|
||||
/// <param name="messageToSend"></param>
|
||||
/// <param name="emailFunc"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessValidationFailedException"></exception>
|
||||
public static async Task<EmailNoticeConfig> GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailNoticeConfig configInfo, MimeMessage messageToSend,
|
||||
Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailFunc)
|
||||
{
|
||||
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
||||
|
||||
|
||||
|
||||
var (topicStr, htmlBodyStr) = isEn_US ? (configInfo.EmailTopic, configInfo.EmailHtmlContent) : (configInfo.EmailTopicCN, configInfo.EmailHtmlContentCN);
|
||||
|
||||
try
|
||||
{
|
||||
//每个场景修改主题 和body的逻辑不一样
|
||||
(topicStr, htmlBodyStr) = emailFunc((topicStr, htmlBodyStr));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//"邮件模板内容有误,填充内容出现问题,请联系运维人员核查"
|
||||
|
||||
throw new BusinessValidationFailedException(I18n.T("CommonEmail_ConfigError"));
|
||||
}
|
||||
|
||||
|
||||
messageToSend.Subject = topicStr;
|
||||
|
||||
var builder = new BodyBuilder();
|
||||
|
||||
builder.HtmlBody = htmlBodyStr;
|
||||
|
||||
messageToSend.Body = builder.ToMessageBody();
|
||||
|
||||
return configInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 项目手动邮件 (需要添加到项目邮件配置中,才发送)
|
||||
/// </summary>
|
||||
/// <param name="configInfo"></param>
|
||||
/// <param name="messageToSend"></param>
|
||||
/// <param name="emailFunc"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BusinessValidationFailedException"></exception>
|
||||
public static async Task<TrialEmailNoticeConfig> GetTrialEmailSubejctAndHtmlInfoAndBuildAsync(TrialEmailNoticeConfig configInfo, MimeMessage messageToSend,
|
||||
Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailFunc)
|
||||
{
|
||||
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
||||
|
||||
Reference in New Issue
Block a user