public ActionResult TestEmail(string address) { var email = new Email(); email.AddMailToAddress(address); email.Subject = "TEST"; email.Body = "Testovací zpráva"; email.Send(); return(RedirectToAction("Index")); }
public static int Create(int userId, string text) { #if DEBUG #else text = text.Replace("<a href=\"", "<a href=\"" + AppUrl); text = text.Replace("<a href='", "<a href='" + AppUrl); #endif var dao = new NotifikaceDao(); var uzivatel = new UzivatelDao().GetById(userId); var notifikace = new Notifikace() { Uzivatel = uzivatel, Text = text, Created = DateTime.Now, Seen = false }; notifikace.Id = (int)dao.Create(notifikace); if (string.IsNullOrEmpty(uzivatel.Email)) { return(notifikace.Id); } var email = new Email { Subject = "Nové upozornění", Body = text }; email.AddMailToAddress(uzivatel.Email); #if DEBUG #else try{ email.Send(); } catch { // ignored } #endif return(notifikace.Id); }