Example #1
0
        ////this is a custom function that create and initialize the editor
        //protected Editor PrepairEditor(Action<Editor> oninit)
        //{
        //    Editor editor = new Editor(System.Web.HttpContext.Current, "editor");

        //    editor.ClientFolder = "/richtexteditor/";
        //    editor.ContentCss = "/Content/example.css";
        //    //editor.ClientFolder = "/Content/richtexteditor/";
        //    //editor.ClientFolder = "/Scripts/richtexteditor/";

        //    editor.Text = "Type here";

        //    editor.AjaxPostbackUrl = Url.Action("EditorAjaxHandler");

        //    if (oninit != null) oninit(editor);

        //    //try to handle the upload/ajax requests
        //    bool isajax = editor.MvcInit();

        //    if (isajax)
        //        return editor;

        //    //load the form data if any
        //    if (this.Request.HttpMethod == "POST")
        //    {
        //        string formdata = this.Request.Form[editor.Name];
        //        if (formdata != null)
        //            editor.LoadFormData(formdata);
        //    }

        //    //render the editor to ViewBag.Editor
        //    ViewBag.Editor = editor.MvcGetString();

        //    return editor;
        //}

        //private IUserMailer _userMailer = new UserMailer();
        //public IUserMailer UserMailer
        //{
        //    get { return _userMailer; }
        //    set { _userMailer = value; }
        //}


        //// GET: /Email/

        //public ActionResult Index()
        //{
        //    return View();


        //}

        //[HttpPost]
        //public ActionResult Index(PizaStore.Models.GroupEmail email)
        //{
        //    if (email != null)
        //    {
        //        UserMailer.Welcome(email).Send();
        //        return View();
        //    }
        //    else
        //    {
        //        return View();
        //    }



        //}


        public ActionResult Index()
        {
            PizaStore.Models.GroupEmail groupEmail = new PizaStore.Models.GroupEmail();
            groupEmail.Text = "this is a test for index page.";

            return(View());
        }
Example #2
0
        public string Index(PizaStore.Models.GroupEmail modelMail)
        {
            PizaStore.DAL.SchoolContext db = new PizaStore.DAL.SchoolContext();


            MailMessage mail = new MailMessage();
            string      Body = modelMail.Text;

            mail.Body = Body;
            foreach (Customer c in db.Customers)
            {
                if ((c.PostCode == modelMail.PostCode) || (c.Birthdate.Date == modelMail.Birthdate.Date && c.Birthdate.Month == modelMail.Birthdate.Month))
                //if (c.Birthdate.Date.Day == modelMail.Birthdate.Day && c.Birthdate.Date.Month == modelMail.Birthdate.Month)
                {
                    mail.To.Add(c.Email);
                    mail.Body += "Available Points:";
                    mail.Body += c.PointsAvailable.ToString();
                    mail.Body += "Redeemable Items:";
                    //foreach (RedeemableItem i in c.RedeemableItems)
                    //{
                    //    mail.Body += i.Name;
                    //    mail.Body += " : ";
                    //    mail.Body += i.Price;
                    //}
                }
            }


            mail.From = new MailAddress("*****@*****.**");
            //mail.Subject = modelMail.Subject;


            mail.IsBodyHtml = true;
            SmtpClient smtp = new SmtpClient();

            smtp.Host = "smtp.sina.com";
            smtp.Port = 587;
            smtp.UseDefaultCredentials = false;
            smtp.Credentials           = new System.Net.NetworkCredential
                                             ("*****@*****.**", "ywfwyfywxwyx_1o");// Enter seders User name and password
            smtp.EnableSsl = false;
            smtp.Send(mail);
            return("Email sent successfully.");
        }