Esempio n. 1
0
        public ActionResult Send(MailingModel model)
        {
            if (AuthContext.CurrentContext.CurrentUser == null)
                return View("Login");

            if (!ModelState.IsValid)
                return View("Index", model);

            var recipients = new List<Recipient>();

            if (model.To == "base" || model.To == "todos")
                using (var session = PersistenceHelper.OpenSession())
                    recipients = new RecipientRepository(session).GetActive().ToList();
            else
                model.To.Replace(",", ";").Replace(" ", "").Split(';').ToList().ForEach(
                        r => recipients.Add(new Recipient {IsActive = true, Email = r, Name = r, CreatedAt = DateTime.Now, Id = 0}));

            var hosts = new Hosts();
            var path = AppDomain.CurrentDomain.BaseDirectory + "MailHosts.xml";
            var sender = new NewsSenderManager(hosts.Load(path));

            sender.ProcessQueue(model.Body, model.Subject, recipients);
            return View("Index", new MailingModel { SendReturn = "enviado com sucesso." });
        }
Esempio n. 2
0
        public ActionResult Test(string q)
        {
            if (AuthContext.CurrentContext.CurrentUser == null)
                return View("Login");

            var hosts = new Hosts();
            var path = AppDomain.CurrentDomain.BaseDirectory + "MailHosts.xml";
            var sender = new NewsSenderManager(hosts.Load(path));
            sender.TestAllHosts(new Recipient{Name = q, Email = q});

            return View("Index", new MailingModel { SendReturn = "Um e-mail de teste foi enviado usando cada um dos SMTPs configurados." });
        }
Esempio n. 3
0
 static void TestAll()
 {
     var hosts = new Hosts();
     var path = AppDomain.CurrentDomain.BaseDirectory + "MailHosts.xml";
     var newsSender = new NewsSenderManager(hosts.Load(path));
     newsSender.TestAllHosts(new Recipient {Email = "*****@*****.**", Name = "chalk"});
     Console.WriteLine("Sent Test");
     Console.Read();
 }
Esempio n. 4
0
 static void SendOne()
 {
     var hosts = new Hosts();
     var path = AppDomain.CurrentDomain.BaseDirectory + "MailHosts.xml";
     var newsSender = new NewsSenderManager(hosts.Load(path));
     newsSender.ProcessQueue("Testando envio", "Testando envio", new List<Recipient>(new[] { new Recipient { Email = "*****@*****.**", Name = "chalk" } }));
     Console.WriteLine("Sent Test");
     Console.Read();
 }