public async Task <NotifyResp> NotifyMsg(NotifyTemplateConfig template, NotifyReq msg) { var config = await GetEmailConfig(); if (config == null) { return(new NotifyResp().WithResp(RespTypes.ObjectNull, "未发现邮件配置信息!")); } var body = msg.body_paras.Aggregate(template.content, (current, p) => current.Replace(string.Concat("{", p.Key, "}"), p.Value)); var emailMsg = new EmailMsgMo { body = body, is_html = template.is_html > 0, subject = string.IsNullOrEmpty(msg.msg_title) ? template.title : msg.msg_title, to_emails = msg.targets }; var eRes = await SendAsync(config, emailMsg); var notifyResp = new NotifyResp().WithResp(eRes); notifyResp.msg_biz_id = msg.msg_Id; return(notifyResp); }
private async Task <NotifyResp> NotifyEmailMsg(NotifyTemplateMo template, NotifyReq msg, bool isFromLogModule) { var emailConfigRes = await GetEmailConfig(isFromLogModule); if (!emailConfigRes.IsSuccess()) { return(new NotifyResp().WithResp(emailConfigRes)); } var body = msg.body_paras.Aggregate(template.content, (current, p) => current.Replace(string.Concat("{", p.Key, "}"), p.Value)); var emailMsg = new EmailMsgMo { body = body, is_html = template.is_html, subject = string.IsNullOrEmpty(msg.msg_title) ? template.title : msg.msg_title, to_emails = msg.targets }; var eRes = await EmailHelper.SendAsync(emailConfigRes.data, emailMsg); var notifyResp = new NotifyResp().WithResp(eRes); notifyResp.msg_biz_id = msg.msg_Id; return(notifyResp); }