コード例 #1
0
        public async Task NotifyBookingByMail(BookingRequestDTO NewBooking)

        {
            MailModels mailmodel = new MailModels();

            mailmodel.ToEmail   = NewBooking.CustomerEmail;
            mailmodel.ToName    = NewBooking.CustomerName;
            mailmodel.StartTime = NewBooking.StartTime.ToString();

            //SG.k - 1qp0IET1KI81dkyb7vGg.171FKbfy0Vk3P9i489GLuQaU0A7G49JPjim7NgYoC1U
            //var apiKey = Environment.GetEnvironmentVariable("SENDGRID_API_KEY");

            mailmodel.subject          = "Booking notification";
            mailmodel.plainTextContent = "Hello " + mailmodel.ToName + "!" + " <br/> You have a confirmed reservation at: " + mailmodel.StartTime + " <br/> with" + mailmodel.ApplicationUserFirstName + " " + mailmodel.ApplicationUserLastName + "<br/> Thank you for booking with us" + "<br/> Best Regards AlltBokat customer support";
            mailmodel.htmlContent      = "Hello" + mailmodel.ToName + "!" + " <br/> You have a confirmed reservation at: " + mailmodel.StartTime + " <br/> with " + mailmodel.ApplicationUserFirstName + " " + mailmodel.ApplicationUserLastName + "<br/> Thank you for booking with us" + "<br/> Best Regards AlltBokat customer support";
            mailmodel.FromEmail        = ("*****@*****.**");
            mailmodel.FromName         = ("Alltbokat Support");


            var from = new EmailAddress(mailmodel.FromEmail, mailmodel.FromName);
            var to   = new EmailAddress(mailmodel.ToEmail, mailmodel.ToName);

            var apiKey = Environment.GetEnvironmentVariable("SENDGRID_API_KEY");
            //var apiKey = "1qp0IET1KI81dkyb7vGg.171FKbfy0Vk3P9i489GLuQaU0A7G49JPjim7NgYoC1U";

            var client = new SendGridClient(apiKey);

            var msg = MailHelper.CreateSingleEmail(from, to, mailmodel.subject, mailmodel.plainTextContent, mailmodel.htmlContent);

            var response = await client.SendEmailAsync(msg);
        }
コード例 #2
0
        public ActionResult SendMail(MailModels mailModels)
        {
            string MailTo      = System.Configuration.ConfigurationManager.AppSettings["MailTo"];
            string MaiPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"];

            MailMessage mail       = new MailMessage();
            SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");

            mail.From = new MailAddress(mailModels.MailAddress);
            mail.To.Add(MailTo);
            mail.Subject = mailModels.Subject;
            mail.Body    = "Client Name Is : " + mailModels.UserName + "Client Mail: " + mailModels.MailAddress + "\nClient Message :" + mailModels.Message;

            SmtpServer.Port = 587;
            SmtpServer.UseDefaultCredentials = false;
            SmtpServer.Credentials           = new System.Net.NetworkCredential(MailTo, MaiPassword);
            if (mailModels.Image != null && mailModels.Image.ContentLength > 1)
            {
                mail.Attachments.Add(new Attachment(mailModels.Image.InputStream, mailModels.Image.FileName));
            }
            SmtpServer.EnableSsl = true;


            try
            {
                SmtpServer.Send(mail);
            }
            catch (Exception ex)
            {
                string Message = ex.Message;
                Console.WriteLine(Message);
            }

            return(RedirectToAction("Index"));
        }
コード例 #3
0
        public ActionResult Contact(MailModels e)
        {
            if (ModelState.IsValid)
            {
                StringBuilder message = new StringBuilder();
                MailAddress   from    = new MailAddress(e.Email.ToString());
                message.Append("Name: " + e.Ime + "\n");
                message.Append("Email: " + e.Email + "\n");
                message.Append("Telephone: " + e.Telephone + "\n\n");
                message.Append(e.Message);

                MailMessage mail = new MailMessage();

                SmtpClient smtp = new SmtpClient();

                smtp.Host = "smtp.mail.yahoo.com";
                smtp.Port = 465;

                System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("yahooaccount", "yahoopassword");

                smtp.Credentials = credentials;
                smtp.EnableSsl   = true;

                mail.From = from;
                mail.To.Add("*****@*****.**");
                mail.Subject = "Test enquiry from " + e.Ime;
                mail.Body    = message.ToString();

                smtp.Send(mail);
            }
            return(View());
        }
コード例 #4
0
        public ActionResult ContactForm(MailModels emailData)
        {
            ViewBag.Message = "Email sended.";

            if (ModelState.IsValid)
            {
                string fromAddress = emailData.Email;
                var    subject     = "Mail from " + emailData.FirstName + " " + emailData.LastName;

                StringBuilder message = new StringBuilder();
                MailAddress   from    = new MailAddress(emailData.Email.ToString());
                message.Append("<b>First Name:</b> " + emailData.FirstName + "<br/>");
                message.Append("<b>Last Name:</b> " + emailData.LastName + "<br/>");
                message.Append("<b>Country:</b> " + emailData.Country + "<br/>");
                message.Append("<b>Email:</b> " + emailData.Email + "<br/>");
                if (!string.IsNullOrWhiteSpace(emailData.Telephone))
                {
                    message.Append("<b>Telephone:</b> " + emailData.Telephone + "<br/><br/>");
                }
                else
                {
                    message.Append("<br/>");
                }
                message.Append(emailData.Message);

                var tEmail = new Thread(() =>
                                        SendEmail("*****@*****.**", fromAddress, subject, message.ToString()));
                tEmail.Start();
            }
            return(View("Contact"));
        }
コード例 #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            MailModels mailModels = db.MailModels.Find(id);

            db.MailModels.Remove(mailModels);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #6
0
 public ActionResult Contact(MailModels e)
 {
     if (ModelState.IsValid)
     {
         //prepare email
         SendEmail(e.Name, e.Email, e.Telephone, e.Message);
     }
     return(View());
 }
コード例 #7
0
 public ActionResult Edit([Bind(Include = "Id,Name,Email,Telephone,Message")] MailModels mailModels)
 {
     if (ModelState.IsValid)
     {
         db.Entry(mailModels).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(mailModels));
 }
コード例 #8
0
        public ActionResult Create([Bind(Include = "Id,Name,Email,Telephone,Message")] MailModels mailModels)
        {
            if (ModelState.IsValid)
            {
                db.MailModels.Add(mailModels);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(mailModels));
        }
コード例 #9
0
        // GET: Mail/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MailModels mailModels = db.MailModels.Find(id);

            if (mailModels == null)
            {
                return(HttpNotFound());
            }
            return(View(mailModels));
        }
コード例 #10
0
 public async Task <ActionResult> Contact(MailModels model)
 {
     if (ModelState.IsValid)
     {
         var body    = "<p>Email From: {0} ({1}) Telefono: {3}</p><p>Message:</p><p>{2}</p>";
         var message = new IdentityMessage();
         message.Subject     = "Contacto Web";
         message.Body        = string.Format(body, model.Name, model.Email, model.Message, model.Telephone);
         message.Destination = "*****@*****.**";
         db.MailModels.Add(model);
         db.SaveChanges();
         await UserManager.EmailService.SendAsync(message);
     }
     return(View(model));
 }
コード例 #11
0
        public void ContactForm()
        {
            //Arrange
            HomeController controller = new HomeController();
            var            mail       = new MailModels()
            {
                FirstName = "FirstNameTest",
                LastName  = "LastNameTest",
                Email     = "*****@*****.**",
                Country   = "CountryTest",
                Message   = "MessageTest",
                Telephone = "TelephoneTest"
            };

            // Act
            ViewResult result = controller.ContactForm(mail) as ViewResult;

            //Assert
            Assert.IsNotNull(result);
        }
コード例 #12
0
        public ActionResult Contact(MailModels e)
        {
            if (ModelState.IsValid)
            {
                //prepare email
                var toAddress   = "*****@*****.**";
                var fromAddress = e.Email.ToString();
                var subject     = "Test enquiry from " + e.FirstName + e.LastName;
                var message     = new StringBuilder();
                message.Append("First Name: " + e.FirstName + "\n");
                message.Append("Last Name: " + e.LastName + "\n");
                message.Append("Email: " + e.Email + "\n");
                message.Append("Telephone: " + e.Telephone + "\n\n");
                message.Append(e.Message);

                //start email Thread
                var tEmail = new Thread(() =>
                                        SendEmail(toAddress, fromAddress, subject, message.ToString()));
                tEmail.Start();
            }
            return(View());
        }
コード例 #13
0
        public ActionResult Contact(MailModels e)
        {
            if (ModelState.IsValid)
            {
                StringBuilder message = new StringBuilder();
                MailAddress   from    = new MailAddress(e.Email.ToString());
                message.AppendLine("Email: " + e.Email);
                message.AppendLine(e.Message);

                MailMessage mail = new MailMessage();

                mail.From = from;
                mail.To.Add("*****@*****.**");
                mail.Subject    = "Yeni Bir Görüş";
                mail.Body       = message.ToString();
                mail.IsBodyHtml = true;

                SendMail(mail);
            }

            ModelState.Clear();
            return(View());
        }
コード例 #14
0
        public ActionResult Contact(MailModels e)
        {
            if (ModelState.IsValid)
            {
                //prepare email
                var toAddress   = "*****@*****.**";
                var fromAddress = e.Email.ToString();
                var subject     = "Test enquiry from " + e.Name;
                var message     = new StringBuilder();
                message.Append("Message from Derrell.com Contact Us page  \n");
                message.Append("Name: " + e.Name + "\n");
                message.Append("Email: " + e.Email + "\n");
                message.Append("Telephone: " + e.Telephone + "\n\n");
                message.Append(e.Message);

                //start email Thread
                var tEmail = new Thread(() =>
                                        SendEmail(toAddress, fromAddress, subject, message));
                tEmail.Start();
                // ViewBag.Message = "Thank you for contacting me.  I will get back to you as soon as possible.";
                return(View("ThankYou"));
            }
            return(View(e));
        }
コード例 #15
0
        public void CreateMail(AppointmentModels appointment)
        {
            CatalogueController catalogue      = new CatalogueController();
            int               process          = catalogue.GetProcessBySubprocess(appointment.SubProcess.ID);
            UserBusiness      userBusiness     = new UserBusiness();
            int               cedula           = appointment.Professional.Cedula;
            List <UserModels> professionals    = userBusiness.GetProfessionalByIdentification(cedula);
            String            nameProfessional = "";

            foreach (UserModels professional in professionals)
            {
                nameProfessional = professional.Name + " " + professional.FirstLastName + " " + professional.SecondLastName;
            }
            string email = (string)Session["email"];

            MailModels mail;
            String     message = "Su cita ha sido programada con éxito. \n " +
                                 "\n\tRESUMEN DE CITA:\n" +
                                 "Fecha: " + appointment.Date + "\n" +
                                 "Hora: " + appointment.Hour + "\n" +
                                 "Paciente: " + appointment.Functionary.Cedula + "\n" +
                                 "Psicólogo: " + nameProfessional +
                                 "\n\n Para cualquier consulta comuniquese al teléfono 2295-4181," +
                                 " al correo [email protected] o a nuestro sitio web de citas para cancelar o modificar su cita";

            switch (process)
            {
            case 1:
                mail = new MailModels("*****@*****.**", email,
                                      "ESTE CORREO ES PARA CONFIRMAR SU CITA DE PROCESO CLINICO EN SAPSO \n" + message,
                                      "CONFIRMACION CITA CLÍNICO", 0);
                break;

            case 2:
                mail = new MailModels("*****@*****.**", email,
                                      "ESTE CORREO ES PARA CONFIRMAR SU CITA DE PROCESO INCIDENTE CRÍTICO EN SAPSO\n" + message +
                                      "IMPORTANTE Complete el formulario adjunto y preséntelo el día de su cita",
                                      "CONFIRMACION CITA INCIDENTES CRITICOS", 2);
                break;

            case 3:
                mail = new MailModels("*****@*****.**", email,
                                      "ESTE CORREO ES PARA CONFIRMAR SU CITA DE PROCESO ARMAS EN SAPSO \n" + message,
                                      "CONFIRMACION DE CITA", 0);
                break;

            case 4:
                mail = new MailModels("*****@*****.**", email,
                                      "ESTE CORREO ES PARA CONFIRMAR SU CITA DE PROCESO CHARLAS EN SAPSO \n" + message,
                                      "CONFIRMACION DE CITA", 0);
                break;

            case 5:
                mail = new MailModels("*****@*****.**", email,
                                      "ESTE CORREO ES PARA CONFIRMAR SU CITA DE PROCESO CAPITULO \"V\" EN SAPSO \n" + message +
                                      "IMPORTANTE: Complete el formulario adjunto y preséntelo el día de su cita",
                                      "CONFIRMACION CITA CAPITULO V", 1);
                break;

            default:
                mail = new MailModels("*****@*****.**", email,
                                      "ESTE CORREO ES PARA CONFIRMAR SU CITA EN SAPSO \n" + message, "CONFIRMACION DE CITA", 0);
                break;
            }
            mail.SendMail();
        }