0

我尝试了以下两种方法,但都返回结果“找不到自动发现服务”。

http://msdn.microsoft.com/en-us/library/gg591267(v=EXCHG.140).aspx

service.Credentials = new NetworkCredential(userData.EmailAddress, userData.Password);

  if (userData.AutodiscoverUrl == null)
  {
    service.AutodiscoverUrl(userData.EmailAddress, RedirectionUrlValidationCallback);
    userData.AutodiscoverUrl = service.Url;
  }
  else
  {
    service.Url = userData.AutodiscoverUrl;
  }

  return service;
}

http://code.msdn.microsoft.com/Exchange-2013-Set-pull-14c8360b#content

static ExchangeService GetBinding()
        {
            // Create the binding.
            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);

        // Define credentials.
        service.Credentials = new WebCredentials("myemail@work.com", "password");

        // Use the AutodiscoverUrl method to locate the service endpoint.
        try
        {
            service.AutodiscoverUrl("myemail@work.com", RedirectionUrlValidationCallback);
        }
        catch (AutodiscoverRemoteException ex)
        {
            Console.WriteLine("Exception thrown: " + ex.Error.Message);
        }

        // Display the service URL.
        Console.WriteLine("AutodiscoverURL: " + service.Url);
        return service;
    }

在一种情况下,我输入了我的电子邮件和密码,在另一种情况下,我输入了硬编码。两者都在尝试 Autodiscoverurl 时挂起,并最终失败并显示消息“无法找到自动发现服务”。我按照教程添加了引用,自动发现出现在 Microsoft.Exchange.WebServices.dll 下......我还缺少什么吗?

4

2 回答 2

0

我不知道你是否已经解决了,我在寻找相同(或类似?)问题的解决方案时碰到了你的帖子。

奇怪的是:由于它在调试模式下完美运行,但没有安装为 Windows 服务,我更改了 Windows 服务属性中的“登录”设置(services.msc,右键单击已安装的服务,属性,登录选项卡) 并将其设置为“本地系统帐户”并选中“允许服务与桌面交互”选项。

这对我有用。

于 2014-11-10T14:12:29.067 回答
0

尝试添加:

service.UseDefaultCredentials = false;

设置凭据后

于 2013-02-19T13:16:31.110 回答