public string ParseEmailTemplate(EmailMessageVM emailMessageVM)
        {
            Engine.Razor.Compile(ConvertViewToString(EmailLayoutView), "EmailMailerLayout");

            var myParsedTemplate = Engine.Razor.RunCompile(ConvertViewToString(SendEmailView), "SendEmailView", null, emailMessageVM);
            return myParsedTemplate;
        }
Ejemplo n.º 2
0
        public IHttpActionResult Send(EmailMessageVM emailVM)
        {
            emailVM.FromEmail = "*****@*****.**";
            var emailService = new EmailService.EmailService();

            emailService.Email(emailVM);

            return Ok();
        }
Ejemplo n.º 3
0
        public void Email(EmailMessageVM emailVM)
        {
            var razorEngineService = new RazorEngineService();

            var msg = new MailMessage(emailVM.FromEmail, emailVM.ToEmail)
            {
                Subject = emailVM.Subject,
                Body = razorEngineService.ParseEmailTemplate(emailVM),
                IsBodyHtml = true
            };

            using (var smtpClient = new SmtpClient())
            {
                smtpClient.Send(msg);
            }
        }