9

当您在网上搜索时,您会发现“如何以编程方式阅读电子邮件”的非常简单的答案......所有网站都在解释大部分与此页面相同的内容。 http://omegacoder.com/?p=454

// depends from Exchange server version      
        service.Credentials = new NetworkCredential("MDR", "password", "zzz");
        service.AutodiscoverUrl("mdr@zzz.be");
        object o = service.FindItems(WellKnownFolderName.Inbox, new ItemView(10));
        FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, new ItemView(10));
        foreach (Item item in findResults.Items)
        {
            Console.WriteLine(item.Subject);
        }

它在执行 autodiscoverURL 行时失败。错误提示“找不到自动发现服务”。

所以我进一步搜索并从 Microsoft https://www.testexchangeconnectivity.com/#&&/wEXAQUBcwUBME93h2+JjI0+MV2gTqcRL0g43z9m找到了这个站点,您可以在这里测试您的邮件服务器......当我传递参数时,我收到以下错误。 ...

但我还是不明白问题是什么?我需要向 DNS 添加记录吗?有人可以帮忙吗?

Attempting to test potential Autodiscover URL https://autodiscover.zzz.be/AutoDiscover/AutoDiscover.xml
 Testing of this potential Autodiscover URL failed.
 Test Steps
 Attempting to resolve the host name autodiscover.ncb.be in DNS.
 The host name resolved successfully.
 Additional Details
 IP addresses returned: 213.246.192.205

Testing TCP port 443 on host autodiscover.ncb.be to ensure it's listening and open.
 The specified port is either blocked, not listening, or not producing the expected response.
  Tell me more about this issue and how to resolve it
 Additional Details
 A network error occurred while communicating with the remote host.
Exception details:
Message: No connection could be made because the target machine actively refused it 213.246.192.205:443
Type: System.Net.Sockets.SocketException
Stack trace:
at System.Net.Sockets.TcpClient.Connect(String hostname, Int32 port)
at Microsoft.Exchange.Tools.ExRca.Tests.TcpPortTest.PerformTestReally()




Attempting to contact the Autodiscover service using the HTTP redirect method.
 The attempt to contact Autodiscover using the HTTP Redirect method failed.
 Test Steps
 Attempting to resolve the host name autodiscover.zzz.be in DNS.
 The host name resolved successfully.
 Additional Details
 IP addresses returned: 213.246.192.205

Testing TCP port 80 on host autodiscover.zzz.be to ensure it's listening and open.
 The port was opened successfully.
ExRCA is checking the host autodiscover.zzz.be for an HTTP redirect to the Autodiscover service.
 ExRCA failed to get an HTTP redirect response for Autodiscover.
 Additional Details
 A Web exception occurred because an HTTP 404 - NotFound response was received from IIS7.



Attempting to contact the Autodiscover service using the DNS SRV redirect method.
 ExRCA failed to contact the Autodiscover service using the DNS SRV redirect method.
 Test Steps
 Attempting to locate SRV record _autodiscover._tcp.ncb.be in DNS.
 The Autodiscover SRV record wasn't found in DNS.
  Tell me more about this issue and how to resolve it
4

4 回答 4

17

如果您已经知道 Exchange 服务器的地址,则不一定需要使用自动发现。请尝试以下操作(有关更多信息,请查看此处

service.Url = new Uri("https://hostname/EWS/Exchange.asmx");

将“主机名”替换为您的 Exchange 服务器的主机名。

于 2011-03-09T20:31:40.547 回答
2

我希望你现在应该有解决方案。这只是为了帮助任何遇到此帖子的人。我在一篇 technet 文章中找到了解决方案,我很适合我,并且对我来说工作正常。

只需将代码中的行替换为以下内容:

service.AutodiscoverUrl("user@yourdomain.com",
delegate
{
     return true;
});

我还有其他一些问题,但与这一点无关。

快乐编码,

桑杰。

于 2011-10-20T17:11:02.767 回答
1

我对自动发现有同样的问题。这不是必需的,您可以指定您的网址,例如

    Uri myUri = new Uri("https://Hostname/ews/exchange.asmx");
    userData.AutodiscoverUrl = myUri;
    service.Url = myUri;

作为主机名,您可以输入服务器 IP 地址,例如 192.168.100.10

或者,如果您使用的是 Outlook,要查找您的 Exchange 服务器主机名(实际上是要使用的整个 url),请转到显示日期和时间的计算机开始栏,您将找到 Outlook 图标,按住 Ctrl + 右键单击​​ Outlook 图标,然后单击“测试电子邮件自动配置”</p>

选中“使用自动发现”复选框。输入托管在该 Exchange Server 上的电子邮件地址及其密码,您将收到一堆 url。使用 1 表示“可用性服务 URL”

于 2013-02-28T15:33:09.187 回答
0

考虑到传递的凭据需要对给定的交换邮箱/服务器具有权限。在我的情况下,使用经过适当许可的不同凭据集有效,但不适用于我试图开始工作的服务帐户。一旦我发现该帐户究竟需要获得什么许可,我将在此处对其进行更新。

更新:我的问题是服务帐户来自与运行 Exchange 2007 实例的域不同的域,即使两者之间存在信任关系。我发现这是 Exchange 2007 中记录在案的已知问题,即它如何在其林中查找帐户。最后必须在交换服务器所在的域上创建一个相同的服务帐户(名称/密码),并将用户名指定为 {exchange_domain}{service_account_name}。调用 EWS 的 Windows 服务作为 {original_domain}{service_account_name} 运行。

作为参考,异常是:Microsoft.Exchange.WebServices.Data.ServiceResponseException:无法获取调用帐户的有效 Active Directory 信息。确认它是有效的 Active Directory 帐户。

于 2011-12-01T00:17:22.153 回答