send1() public method

public send1 ( ) : string
return string
コード例 #1
0
ファイル: PollController.cs プロジェクト: Marknel/dbPOLL
        public ActionResult AssignPollCreator(int pollid, int[] selectedObjects, String pollname)
        {
            if (Session["uid"] == null || Session["uid"].ToString().Equals(""))
            {
                return RedirectToAction("Index", "Home");
            }
            if ((int)Session["user_type"] < User_Type.POLL_CREATOR)
            {
                return RedirectToAction("Invalid", "Home");
            }

            String errorString = "";

            new pollModel().assignPoll(pollid, selectedObjects);

            Assign_PollMasters pollMasters = new Assign_PollMasters();

            pollMasters.assigned = new userModel().displayAssignedUsers(pollid, User_Type.POLL_CREATOR);
            pollMasters.unassigned = new userModel().displayUnassignedUsers(pollid, User_Type.POLL_CREATOR);

                foreach (int id in selectedObjects)
                {
                    userModel u = new userModel();
                    u = u.getUser(id);
                    EmailController mail = new EmailController(pollname, u.username);

                    string mailSuccess = mail.send1();
                    if (!mailSuccess.Equals("Email sent successfully"))
                    {
                        errorString += u.username + "\n";
                        //throw new Exception(mailSuccess);
                    }
                }

            if(errorString.Length != 0)
                ViewData["emailError"] = "Could not send email to following Users: \n" + errorString;

            ViewData["pollid"] = pollid;
            ViewData["pollname"] = pollname;
            return View(pollMasters);
        }