无法找到自动发现服务
我有使用 Exchange Web 服务(EWS 1.1 API)发送电子邮件的代码。如果我使用硬编码的参数值,也不例外,例如:
service.AutodiscoverUrl("[email protected]",
delegate
{
return true;
});
但是如果我尝试使用变量,那么我在发现 URL 时会收到错误,“无法找到自动发现服务”。
string userName = "[email protected]";
service.AutodiscoverUrl(userName,
delegate
{
return true;
});
有没有办法通过 autodiscoverurl 方法使用变量?我做错了什么?
桑杰
I have code to send email using Exchange Web Services (EWS 1.1 API). There is no exception if I use the hardcoded parameter values, like:
service.AutodiscoverUrl("[email protected]",
delegate
{
return true;
});
But If I try to use a variable then I am getting error while discovering URL, "The Autodiscover service couldn't be located".
string userName = "[email protected]";
service.AutodiscoverUrl(userName,
delegate
{
return true;
});
Is there any way to use variables with autodiscoverurl method? What am I doing wrong?
Sanjay
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这不太可能是导致问题的原因。通常,如果自动发现失败,是因为凭据无效或网络连接问题。
在 ExchangeService 实例上启用跟踪(MSDN 文章) 看看发生了什么。
It's very unlikely that this is causing the problem. Typically, if AutoDiscover fails, it's because of invalid credentials or network connectivity issues.
Enable tracing on the ExchangeService instance (MSDN article) to see what is going on.
我意识到这篇文章已经有几年了,但我只是为了文档的目的提供一个额外的解决方案。
造成此行为的另一个可能原因是,当 EWS 服务器仅支持 TLS 1.0 时,客户端尝试强制使用 TLS 1.2 连接。我正打算放弃对这种行为的调查——一个 EWS 应用程序在一个盒子上运行,而同一个应用程序在另一个盒子上失败(转到同一个邮箱)——问题是一台机器可以协商 TLS 1.0,它可以工作,而另一个只能执行 TLS 1.2,但失败了。在注册表中启用客户端 TLS 1.0 出站连接(
HKLM\System\CCS\Services\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client
,DWORD 值“Enabled”设置为 0x1 修复了该问题。无需重新启动必需的。I realize this post is a few years old, but I'm offering an additional solution simply for the sake of documentation.
Another possible cause of this behavior is the client is attempting to force a TLS 1.2 connection when the EWS server is supporting only TLS 1.0. I was about to surrender investigating this very behavior - an EWS app worked on one box, and the same app failed on a different box (going to the same mailbox) - and the problem was one machine could negotiate TLS 1.0, which worked, while the other could do TLS 1.2 only, which failed. Enabling client TLS 1.0 outbound connections in the registry (
HKLM\System\CCS\Services\SecurityProviders\SCHANNEL\Protocols\TLS 1.0\Client
, DWORD value 'Enabled' set to 0x1 fixed the problem. No reboot required.只是为了添加另一个解决方案 - 由于与上面的 David W 相反的问题,我一直在苦苦挣扎 - 我的交换服务器仅支持 TLS1.2,但我的应用程序(.net 4.5)默认情况下仅支持 1.0。
通过添加:
到我的应用程序启动代码来修复。我相信从 .net 4.6 开始默认启用此功能
我收到的具体错误是:
And just to add another solution - I was struggling because of the opposite problem to David W above - my exchange server only supported TLS1.2, but my app (.net 4.5) only supported 1.0 by default.
Fixed by adding:
to my app startup code. I believe this is enabled by default for .net 4.6 onwards
The specific error I was getting was:
我遇到了同样的问题并解决了添加 .ToString():
I had the same issue and solved adding .ToString():