public ActionResult ConstructEmail(string user_email)
        {
            //User role security check
            int role = (int)HttpContext.Session["userRole"];

            //Ensure user is contributor
            if (role == UserRole.AMBASSADOR)
            {

                //Input checks
                if (user_email == null || user_email == "")
                {
                    return RedirectToAction(ActionName.AN_VIEW_ACTIVE_PROJECTS, PermissionSpace.PS_AMBASSADOR_HOME);
                }

                AmbassEmailViewModel email = new AmbassEmailViewModel();

                //Assign user email to necessary email view model field
                email.SendTo = user_email;

                return View(email);

            }
            else if (role == UserRole.ADMIN)
            {
                //Redirect to correct
                return RedirectToAction(ActionName.AN_CONSTRUCT_EMAIL, PermissionSpace.PS_ADMIN_HOME,
                    new { user_email = user_email });
            }
            else
            {
                //Output error message box
                return RedirectToAction(ActionName.AN_PERMISSIONS_INVALID, PermissionSpace.PS_AMBASSADOR_HOME);
            }
        }
        public bool SendEmail(object email)
        {
            //Input checks
            if (email == null)
            {
                return(false);
            }

            if (this.GetType() == typeof(AdminAccess))
            {
                // *** Update to allow different client to be used
                try
                {
                    //Cast object as appropriate view model
                    AdminEmailViewModel vm_email = new AdminEmailViewModel();

                    vm_email = (AdminEmailViewModel)email;

                    //Configure email for gmail server send. Gmail account is default that was
                    //created specifically for idea bank
                    WebMail.SmtpServer = "smtp.gmail.com";
                    WebMail.SmtpPort   = 25;
                    WebMail.EnableSsl  = true;
                    WebMail.UserName   = "******";
                    WebMail.Password   = "******";
                    WebMail.From       = "*****@*****.**";

                    //Value checks
                    if (vm_email.SendTo == null || vm_email.SendTo == "")
                    {
                        return(false);
                    }
                    if (vm_email.Subject == null)
                    {
                        vm_email.Subject = "Re: Commerce IdeaBank "; //Use default Subject
                    }
                    if (vm_email.EmailBody == null || vm_email.EmailBody == "")
                    {
                        return(false);
                    }

                    //Send email
                    WebMail.Send(vm_email.SendTo, vm_email.Subject, vm_email.EmailBody, vm_email.SentFrom,
                                 vm_email.CCTo, null, true, null, null, null, null, vm_email.Priority, null);

                    //Indicate successful status
                    return(true);
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);

                    //Indicate message send failure
                    return(false);
                }
            }
            else if (this.GetType() == typeof(AmbassadorAccess))
            {
                //For ambassador email

                // *** Update to allow different client to be used
                try
                {
                    //Cast object as appropriate view model
                    AmbassEmailViewModel vm_email = new AmbassEmailViewModel();

                    vm_email = (AmbassEmailViewModel)email;

                    //Configure email for gmail server send. Gmail account is default that was
                    //created specifically for idea bank
                    WebMail.SmtpServer = "smtp.gmail.com";
                    WebMail.SmtpPort   = 25;
                    WebMail.EnableSsl  = true;
                    WebMail.UserName   = "******";
                    WebMail.Password   = "******";
                    WebMail.From       = "*****@*****.**";

                    //Value checks
                    if (vm_email.SendTo == null)
                    {
                        return(false);
                    }
                    if (vm_email.Subject == null)
                    {
                        vm_email.Subject = "Re: Commerce IdeaBank "; //Use default Subject
                    }
                    if (vm_email.EmailBody == null || vm_email.EmailBody == "")
                    {
                        return(false);
                    }
                    if (vm_email.EmailBody == null || vm_email.EmailBody == "")
                    {
                        return(false);
                    }

                    //Send email
                    WebMail.Send(vm_email.SendTo, vm_email.Subject, vm_email.EmailBody, vm_email.SentFrom,
                                 vm_email.CCTo, null, true, null, null, null, null, vm_email.Priority, null);

                    //Indicate successful status
                    return(true);
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);

                    //Indicate message send failure
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        public ActionResult ConstructEmail(AmbassEmailViewModel user_email)
        {
            //User role security check
            int role = (int)HttpContext.Session["userRole"];

            //Ensure user is contributor
            if (role == UserRole.AMBASSADOR)
            {

                //Input checks
                if (user_email == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); }

                if (ModelState.IsValid)
                {
                    //Assign user email to necessary email view model field
                    if (ambassador.SendEmail(user_email))
                    {
                        //Email was sent.
                        //Output confirmation message for user ***
                        MessageBox.Show("Your email is on its way!", Popups.POP_UP_TITLE, MessageBoxButtons.OK,
                             MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0x40000);

                        //Return to original view
                        return RedirectToAction(ActionName.AN_VIEW_ACTIVE_PROJECTS, PermissionSpace.PS_AMBASSADOR_HOME);
                    }
                    else
                    {
                        //Gracefully indicate error
                        MessageBox.Show("Oh no! An error occurred while sending your email. " +
                            "We'll return you to email construction and reset the values with " +
                            "your entries.", Popups.POP_UP_TITLE, MessageBoxButtons.OK,
                             MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0x40000);

                        //Redirect to reconstruct email *** won't actually re-route value correctly
                        return RedirectToAction(ActionName.AN_RECONSTRUCT_EMAIL, PermissionSpace.PS_AMBASSADOR_HOME,
                        new { Value = (AmbassEmailViewModel)user_email });
                    }
                }

                return RedirectToAction(ActionName.AN_VIEW_ACTIVE_PROJECTS, PermissionSpace.PS_AMBASSADOR_HOME);

            }
            else if (role == UserRole.ADMIN)
            {
                //Output error message box
                MessageBox.Show(" :-( We're extremely sorry about the inconvenience! " +
                    "There was an error in the sytem with your permissions which will " +
                    "require that you re-write your previous email. We'll redirect you " +
                    "to the correct email page.", Popups.POP_UP_TITLE, MessageBoxButtons.OK,
                MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0x40000);

                //Delete email and redirect to recovery point
                return RedirectToAction(ActionName.AN_CONSTRUCT_EMAIL, PermissionSpace.PS_ADMIN_HOME,
                    new { user_email = user_email.SendTo});
            }
            else
            {
                //Output error message box
                return RedirectToAction(ActionName.AN_PERMISSIONS_INVALID, PermissionSpace.PS_AMBASSADOR_HOME);
            }
        }