C#编程读取从Exchange服务器的邮件 [英] c# programmatically reading emails from the Exchange server

查看:432
本文介绍了C#编程读取从Exchange服务器的邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当你在网上搜索,你会发现如何阅读电子邮件编程......阿尔网站的解释大多是同这样的页面很简单的答案。
http://omegacoder.com/?p=454

  //依赖从Exchange服务器版本
service.Credentials =新的NetworkCredential(MDR,密码,ZZZ);
service.AutodiscoverUrl(mdr@zzz.be);
对象o = service.FindItems(WellKnownFolderName.Inbox,新ItemView控件(10));
FindItemsResults<项目> findResults = service.FindItems(WellKnownFolderName.Inbox,新ItemView控件(10));
的foreach(在findResults.Items项项)
{
Console.WriteLine(item.Subject);
}



它时,它执行autodiscoverURL线失败。错误说自动发现服务找不到。



于是我进一步一派,从微软的 https://www.testexchangeconnectivity.com/#&&/wEXAQUBcwUBME93h2+JjI0+MV2gTqcRL0g43z9m 在这里,你可以测试你的邮件服务器....
当我通过我得到的参数下面....



误差

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



 试图测试潜在的自动发现URL https://autodiscover.zzz.be/AutoDiscover/AutoDiscover.xml $这种潜在的自动发现URL的b $ b测试失败。 
测试步骤
试图解决DNS主机名autodiscover.ncb.be。
的主机名顺利解决。
附加详情
的IP地址返回:213.246.192.205

测试TCP端口443上的主机autodiscover.ncb.be以确保其在听和开放。
指定的端口将被阻止,不听,还是没有产生预期的反应。
告诉我更多有关此问题以及如何解决它
附加详情
,同时与远程主机通信时发生网络错误。
异常详细信息:
消息:无连接可以作出,因为目标机器积极地拒绝它213.246.192.205:443
类型:System.Net.Sockets.SocketException
堆栈跟踪:
在System.Net.Sockets.TcpClient.Connect(字符串主机名,端口的Int32)
在Microsoft.Exchange.Tools.ExRca.Tests.TcpPortTest.PerformTestReally()




试图使用HTTP重定向方法联系自动发现服务。
的尝试使用HTTP重定向方法未能联系上自动发现。
测试步骤
试图解决DNS主机名autodiscover.zzz.be。
的主机名顺利解决。
附加详情
的IP地址返回:213.246.192.205

测试TCP端口80上的主机autodiscover.zzz.be以确保其在听和开放。
端口已成功打开。
ExRCA正在检查HTTP主机autodiscover.zzz.be重定向到自动发现服务。
ExRCA无法获得自动发现一个HTTP重定向响应。从IIS7收到NOTFOUND响应 - 因为HTTP 404发生
附加详情
的Web异常。



尝试使用​​DNS SRV重定向方法联系自动发现服务。
ExRCA失败使用DNS SRV重定向方法联系自动发现服务。
测试步骤
试图找到DNS SRV记录_autodiscover._tcp.ncb.be。
自动发现SRV记录在DNS中没有被发现。
告诉我更多有关此问题以及如何解决它


解决方案

您不一定需要使用自动搜索,如果你已经知道你的Exchange服务器的地址。请尝试以下代替(更多信息,请看 href=\"http://msdn.microsoft.com/en-us/library/dd633692%28v=exchg.80%29.aspx\">:

  service.Url =新的URI(HTTPS://hostname/EWS/Exchange.asmx); 

替换主机名与主机名Exchange服务器。


When you search on web you will find very easy answers for "How to read emails programmatically"... Al the websites are explaining most of the same like this page. 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);
        }

it fails when it executes the autodiscoverURL line. The error says "The Autodiscover service couldn't be located."

So I googled further and found this site from Microsoft https://www.testexchangeconnectivity.com/#&&/wEXAQUBcwUBME93h2+JjI0+MV2gTqcRL0g43z9m Here you can test your mail server.... When I pass the parameters I get the error below....

But I still don't understand what the problem is? Do I need to add a record to DNS ? Can someone help?

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

解决方案

You don't necessarily need to use the autodiscovery if you already know the address of your exchange server. Try the following instead (for more info, look here:

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

Replace "hostname" with the hostname for your exchange server.

这篇关于C#编程读取从Exchange服务器的邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆