Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult SendMails()
- {
- AccountVM acc = new AccountVM();
- BorrowingVM bor = new BorrowingVM();
- BookVM book = new BookVM();
- var emails = from b in book.Get_list()
- from o in bor.Get_list()
- from a in acc.Get_list()
- where o.BookID==b.BookID && a.AccountID==o.ReaderID && o.Returned==false && o.Return_date < DateTime.Now
- select new
- {
- a.Email,
- b.Title
- };
- GMailer.GmailUsername = "panmail1212p@gmail.com";
- GMailer.GmailPassword = "zaq1@wsx";
- GMailer mailer = new GMailer();
- foreach (var e in emails)
- {
- mailer.ToEmail = e.Email;
- mailer.Subject = "BIBLIOTEKA - Zwrot książki";
- mailer.Body = "Prosimy o zwrot książki '" + e.Title + "' !";
- mailer.IsHtml = true;
- mailer.Send();
- }
- ViewBag.Mails1 = "Wysłano próśb " + emails.Count();
- var emails1 = from b in book.Get_list()
- from o in bor.Get_list()
- from a in acc.Get_list()
- where o.BookID == b.BookID && a.AccountID == o.ReaderID && o.Returned == false && o.Return_date.Date == DateTime.Now.Date.AddDays(1)
- select new
- {
- a.Email,
- b.Title
- };
- foreach (var e in emails1)
- {
- mailer.ToEmail = e.Email;
- mailer.Subject = "BIBLIOTEKA - Przypomnienie o zwrocie książki!";
- mailer.Body = "Został jeden dzień do zwrotu książki '" + e.Title + "' ! Po upływie czasu kara zastanie naliczona!";
- mailer.IsHtml = true;
- mailer.Send();
- }
- ViewBag.Mails2 = "Wysłano przypomnień " + emails1.Count();
- return View("Admin");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement