Exemplo n.º 1
0
        /// <summary>
        /// Renders the email view and builds a <see cref="MailMessage"/>.
        /// </summary>
        /// <param name="email">The email to render.</param>
        /// <returns>A <see cref="MailMessage"/> containing the rendered email.</returns>
        public async Task <MailMessage> CreateMailMessageAsync(IEmail email)
        {
            var templateOutput = this.Render(email);
            var mailMessage    = await emailParser.ParseAsync(templateOutput, email);

            return(mailMessage);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Renders the email view and builds a <see cref="MailMessage"/>. Does not send the email.
        /// </summary>
        /// <param name="email">The email to render.</param>
        /// <returns>A <see cref="MailMessage"/> containing the rendered email.</returns>
        public async Task <MailMessage> CreateMailMessageAsync(Email email)
        {
            var rawEmailString = await emailViewRenderer.RenderAsync(email);

            emailParser = new EmailParser(emailViewRenderer);
            var mailMessage = await emailParser.ParseAsync(rawEmailString, email);

            return(mailMessage);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Renders the email view and builds a <see cref="MailMessage"/>. Does not send the email.
        /// </summary>
        /// <param name="email">The email to render.</param>
        /// <returns>A <see cref="MailMessage"/> containing the rendered email.</returns>
        public async Task <MailMessage> CreateMailMessageAsync(Email email)
        {
            var rawEmailString = await emailViewRenderer.RenderAsync(email);

            emailParser = new EmailParser(emailViewRenderer);
            var mailMessage = await emailParser.ParseAsync(rawEmailString, email);

            if (mailMessage.From == null || mailMessage.From.Address == null)
            {
                mailMessage.From = new MailAddress(this.options.FromAddress);
            }
            return(mailMessage);
        }