EWS托管API自动发现运行速度非常慢

时间:2016-04-07 10:16:04

标签: exchangewebservices ews-managed-api

我正在使用EWS API来使用Outlook 365邮件服务。

当我执行任何邮件操作时,它运行缓慢。

我写了下面提到的代码:

ExchangeService service = new    ExchangeService(ExchangeVersion.Exchange2013_SP1);
service.Credentials = new WebCredentials("usernm", "pwd");  
service.EnableScpLookup = false;  
service.AutodiscoverUrl("user",RedirectionUrlValidationCallback);

最后一行在连接成功之前需要16秒 有没有办法让性能更快?

1 个答案:

答案 0 :(得分:0)

很难说...... 不说这就是答案

但试试这个并告诉我。

我看到不同之处在于我没有在autoDiscoverUrl中传递RedirectionUrlValidationCallback而我没有设置EnableScpLookup标志,也不知道它是什么。 告诉我

public ExchangeService GetService( string autoDiscoverEmailAddress, string authEmailAddress,string authEmailPassword, string domain = null, ExchangeVersion verion = ExchangeVersion.Exchange2010_SP2 )
        {
            try 
            {
                ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;

                ExchangeService svc = new ExchangeService(verion);

                //svc.UseDefaultCredentials = true;

                if (!string.IsNullOrWhiteSpace(domain))
                {
                    svc.Credentials = new WebCredentials(authEmailAddress, authEmailPassword, domain);
                }
                else
                {
                    svc.Credentials = new WebCredentials(authEmailAddress, authEmailPassword);
                }
                svc.AutodiscoverUrl(autoDiscoverEmailAddress);


                return svc;
            }
            catch (Exception) 
            {
                throw;
            }

        }