Пример #1
0
        public HttpStatusCode EnviarTurno([FromBody] TurnoModel turno)
        {
            var    fromAddress  = new MailAddress("*****@*****.**", "[CVO] Turno");
            var    toAddress    = new MailAddress("*****@*****.**", "Clínica Veterinaria del Oeste");
            string fromPassword = "******";
            string subject      = "[CVO] Pedido de Turno de " + turno.Nombre;
            string body         = GenerarEmailTurno(turno);

            var smtp = new SmtpClient
            {
                Host                  = "smtp.gmail.com",
                Port                  = 587,
                EnableSsl             = true,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(fromAddress.Address, fromPassword)
            };

            var message = new MailMessage(fromAddress, toAddress)
            {
                Subject    = subject,
                Body       = body,
                IsBodyHtml = true
            };

            smtp.Send(message);
            return(HttpStatusCode.OK);
        }
Пример #2
0
        private string GenerarEmailTurno(TurnoModel turno)
        {
            var    time   = DateTime.Now;
            string estilo = "<head><style>p { font-size: 16px; }</style></head>";
            string body   = estilo + "<body>";

            body += "<b>Nombre:</b> " + turno.Nombre + "<br/>";
            body += "<b>Mascota:</b> " + turno.Mascota + "<br/>";
            body += "<b>Email:</b> " + turno.Email + "<br/>";
            body += "<b>Fecha deseada:</b> " + turno.Fecha + "<br/>";
            body += "<b>Mensaje:</b>";
            body += "<p>" + turno.Mensaje + "</p>";
            body += "<hr/><i>Mensaje envíado el " + time.ToShortDateString() + " a las " + time.ToShortTimeString() + "</i><br/>";
            body += "<i>Clínica Veterinaria del Oeste - Turnos</i>";
            body += "</body>";
            return(body);
        }