/// <summary> /// logon using domain, user and password /// </summary> /// <param name="sDomain">the domain for login</param> /// <param name="sUser">user name</param> /// <param name="sPassword">password</param> /// <returns>true if success</returns> public bool logon(string sDomain, string sUser, string sPassword, bool bProxy, string sWebProxy, int iWebProxyPort) { OnStateChanged(new StatusEventArgs(StatusType.busy, "logon...")); bool bRet = false; _userData = new UserData(sDomain, sUser, sPassword, bProxy, sWebProxy, iWebProxyPort); try { // Or use NetworkCredential directly (WebCredentials is a wrapper // around NetworkCredential). _service.Credentials = new NetworkCredential(sUser, sPassword, sDomain); if(_userData.bUseProxy) _service.WebProxy = new WebProxy(_userData.WebProxy, _userData.WebProxyPort); _service.Url = new Uri(ExchangeWebServiceURL); helpers.addLog("connected to: " + _service.Url.ToString()); OnStateChanged(new StatusEventArgs(StatusType.idle, "connected to: " + _service.Url.ToString())); OnStateChanged(new StatusEventArgs(StatusType.ews_started, "ews started")); bRet = true; } catch (Exception ex) { helpers.addLog("Exception: " + ex.Message); OnStateChanged(new StatusEventArgs(StatusType.error, "logon failed: " + ex.Message)); OnStateChanged(new StatusEventArgs(StatusType.ews_stopped, "ews logon failed")); } return bRet; }
public OutlookMail(ref LicenseMail licenseMail) { _licenseMail = licenseMail; _userData = new UserData(); }