public ActionResult CreateMailbox(FormCollection _POST) { try { var NewPassword = CommonCAS.GeneratePassword(); CustomMailbox newMailbox = new CustomMailbox() { UserName = _POST["username"].Trim(), DomainName = _POST["domainname"], DisplayName = _POST["displayname"].TrimEnd(), Organization = _POST["organization"], Password = CommonCAS.GeneratePassword(), Type = _POST["type"], }; if (_POST["emailaddresses"] != null) { newMailbox.EmailAddresses = _POST["emailaddresses"].Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).ToList <string>(); } else { newMailbox.EmailAddresses = new List <string>(); } model.Mailbox = newMailbox; CommonCAS.Log(string.Format("has run Mail/CreateMailbox() to create {0} for {1}.", newMailbox.DisplayName, model.Mailbox.Organization)); using (MyPowerShell ps = new MyPowerShell()) { ps.CreateMailbox(newMailbox); var result = ps.Invoke(); } model.OKMessage.Add("Successfully created mailbox " + newMailbox.DisplayName + "for" + newMailbox.Organization); CommonCAS.Stats("Mail/CreateMailbox"); return(View("CreateMailboxSuccess", model)); } catch (Exception exc) { CommonCAS.Log("Exception: " + exc.Message); model.ActionFailed = true; model.Message = exc.Message; return(View(model)); } }