Ejemplo n.º 1
0
        private string FormatTemplate(string template, EmailRequestModel emailRequest)
        {
            foreach (var placeholder in emailRequest.PlaceholderContent)
            {
                template = template.Replace($"%%{placeholder.Key}%%", HttpUtility.HtmlEncode(placeholder.Value));
            }

            return(template);
        }
Ejemplo n.º 2
0
        public async Task <Email> BuildEmail(EmailRequestModel emailRequest)
        {
            _logger.LogInformation("Build email");

            var template = await GetTemplate(emailRequest.TemplateType);

            template = FormatTemplate(template, emailRequest);
            var emailModel = new Email
            {
                FromName   = emailRequest.SenderName,
                FromEmail  = "*****@*****.**",
                To         = emailRequest.Address,
                SenderName = emailRequest.SenderName,
                Subject    = EmailConstants.GetSubject(emailRequest.TemplateType),
                Content    = template,
                Attachment = emailRequest.Attachment
            };

            return(emailModel);
        }
Ejemplo n.º 3
0
        public async Task SendAsync(EmailRequestModel emailRequest, CancellationToken cancellationToken = default)
        {
            var email = await _emailBuilder.BuildEmail(emailRequest);

            await SendAsync(email, cancellationToken);
        }