string CreateBodyForEmail(AdjusmentEbtNotificationEmail emailInfo, MessageTemplate emailTemplate) { var tablebody = @" <div><table border="" 1"" cellspacing="" 0"" cellpadding="" 0"" > <tbody><tr><td width="" 89"" ><p><strong>Concepto</strong></p></td><td width="" 89"" > <p><strong>Número</strong><strong> de Cheque</strong></p></td> <td width="" 89"" ><p><strong>Fecha</strong><strong> de emisión</strong></p> </td><td width="" 89"" ><p><strong>Desde</strong></p></td> <td width="" 89"" ><p><strong>Hasta</strong></p></td> <td width="" 89"" ><p><strong>Días</strong></p></td> <td width="" 89"" ><p><strong>Monto</strong></p></td></tr>"; foreach (var row in emailInfo.PaymentTable) { tablebody += String.Format(@"<tr><td width="" 89"" >{0}</td> <td width="" 89"" >{1}</td> <td width="" 89"" >{2}</td> <td width="" 89"" >{3}</td> <td width="" 89"" >{4}</td> <td width="" 89"" >{5}</td> <td width="" 89"" >{6}</td> </tr></tbody> </table></div>", row.Concept, row.TransactionNumber, row.AdjustmentRequestedDate, row.FromDate, row.ToDate, row.PaymentDay, row.Amount); } tablebody += @"</tbody> </table> </div>"; return (emailTemplate.Body.Replace("%Lesionado%", emailInfo.Lesionado) .Replace("%NumeroCaso%", emailInfo.NumeroCaso) .Replace("%NumeroEBT%", emailInfo.NumeroCuentaEbt) .Replace("%Desglose%", tablebody)); }
private void SendNotificationEmail(Dictionary <string, List <AdjusmentEbtViewModel> > injuredPerson) { MessageTemplate templateEBT = MessageTemplateService.GetMessageTemplate("AjustesEBT.Documentar.EmailTemplate"); if (templateEBT.IsNull()) { Logger.Error("No se ha configurado la Plantilla de E-Mail para Solicitudes EBT"); return; } foreach (var item in injuredPerson) { var paymentListToBeNotified = new AdjusmentEbtNotificationEmail(); paymentListToBeNotified.Lesionado = item.Key; paymentListToBeNotified.NumeroCaso = item.Value[0].CaseNumber; paymentListToBeNotified.NumeroCuentaEbt = item.Value[0].EbtNumber; paymentListToBeNotified.PaymentTable = item.Value; try { var setting_ebt_mail_from = SettingService.GetSettingValueByName("AjustesEBT.Notificaciones.Email.To"); var setting_ebt_mail_to = SettingService.GetSettingValueByName("AjustesEBT.Notificaciones.Email.From"); var ebt_mail_from = new MailAddress(!string.IsNullOrEmpty(setting_ebt_mail_from) ? setting_ebt_mail_from : "*****@*****.**"); var ebt_mail_to = new List <MailAddress>(); var ebt_mail_body = CreateBodyForEmail(paymentListToBeNotified, templateEBT); ebt_mail_to.Add(new MailAddress(!string.IsNullOrEmpty(setting_ebt_mail_to) ? setting_ebt_mail_to : "*****@*****.**")); templateEBT.Subject = templateEBT.Subject.Replace("@tipoajuste", item.Value[0].AdjustmentType); //por Debito o Credito y @concepto templateEBT.Subject = templateEBT.Subject.Replace("@concepto", item.Value[0].Concept); EmailSenderService.SendEmail(templateEBT.Subject, ebt_mail_body, ebt_mail_from, ebt_mail_to, null, null, null, null); } catch (Exception ex) { Logger.Error("No se ha configurado E-Mail para Solicitudes EBT", ex); } } }