Exemplo n.º 1
0
        /// <summary>
        /// Retreive the EWS Authentication Token
        /// </summary>
        /// <returns></returns>
        public async Task <AuthenticationResult> RetreiveToken()
        {
            if (Ewstoken == null || Ewstoken.ExpiresOn >= DateTimeOffset.Now)
            {
                Ewstoken = await EWSConstants.AcquireTokenAsync();
            }

            return(Ewstoken);
        }
Exemplo n.º 2
0
        public async System.Threading.Tasks.Task CreateExchangeServiceAsync(bool enableTrace = false)
        {
            var tokens = await EWSConstants.AcquireTokenAsync();

            Tokens = tokens;

            ExchangeService = new ExchangeService(ExchangeVersion.Exchange2013, TimeZoneInfo.Local)
            {
                Url         = new Uri($"{EWSConstants.EWSUrl}/EWS/Exchange.asmx"),
                Credentials = new OAuthCredentials(Tokens.AccessToken)
            };

            if (enableTrace)
            {
                ExchangeService.TraceEnabled = enableTrace;
                ExchangeService.TraceFlags   = TraceFlags.All;
            }
        }