Example #1
0
        public ActionResult Create([Bind(Include="id,description,name,periode")] eve eve)
        {
            IUser service = null;
            service = new Service.UserService();


            if (ModelState.IsValid)
            {
                db.eves.Add(eve);
                db.SaveChanges();


               
                System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                foreach (var item1 in service.getUsers())
                {
                mail.To.Add(item1.email);
                }
                mail.From = new MailAddress("*****@*****.**","tntroc");
                mail.Subject = "New Event Notification";
                string Body = eve.description;
                mail.Body = Body;
                mail.IsBodyHtml = true;
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "smtp.gmail.com";
                smtp.Port = 587;
                smtp.UseDefaultCredentials = false;
                smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "50020892");// Enter seders User name and password
                smtp.EnableSsl = true;
                smtp.Send(mail);
              









                return RedirectToAction("Index");
            }

            return View(eve);
        }