//
 // GET: /ExchangeAccount/Create
 public ActionResult Create()
 {
     ExchangeAccount ews = new ExchangeAccount();
     ews.init(db);
     FillVersionsSelectList();
     return View(ews);
 }
        private void resolveAccount(ExchangeAccount account)
        {
            ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;

            ExchangeService service = new ExchangeService((ExchangeVersion)account.EwsVersion)
            {
                Credentials = new WebCredentials(
                    account.Account,
                    RsaUtil.Decrypt(account.Password)
                    ),
            };

            try
            {
                if (!string.IsNullOrWhiteSpace(account.Url))
                {
                    service.Url = new Uri(account.Url);
                }
                else
                {
                    service.AutodiscoverUrl(account.Account, RedirectionUrlValidationCallback);
                }

                var match = service.ResolveName(account.Account);
                if (match.Count == 0)
                {
                    throw new Exception();
                }
            }

            catch (Exception)
            {
                ModelState.AddModelError("Account", Resources.CouldNotBeResolved);
            }
        }