Esempio n. 1
0
        private string PrepararHtml(coredto.Notificacao notificacao)
        {
            var responseEmpresaUrls = empresaClient.ObterUrls(notificacao.EmpresaId);

            var local = Directory.GetCurrentDirectory();

            var caminhoHtml = string.Concat(local, $"/email-templates/padrao.html");

            var template = System.IO.File.ReadAllText(caminhoHtml);
            var html     = new StringBuilder(template);

            html.Replace("#BODY#", string.Join(null, notificacao.Paragrafos.Select(s => $"<p>{s}</p>")));
            html.Replace("#NOME#", notificacao.Nome);
            html.Replace("#URLAPP#", responseEmpresaUrls.Item.UrlApp);
            html.Replace("#EMPRESAID#", notificacao.EmpresaId.ToString());

            return(html.ToString());
        }
Esempio n. 2
0
        public void Enviar(coredto.Notificacao notificacao)
        {
            var html = PrepararHtml(notificacao);

            this.smtpService.Send(notificacao.Destinatario, notificacao.Nome, notificacao.Titulo, html);
        }