如何连接到Exchange? [英] How to connect to Exchange?
问题描述
我想在公司中最简单的事情-取回邮件.我尝试了Imap-没有成功,(ImapX根本没有连接,并且没有显示错误),我来到了EWS.
The simplest thing I want in my company - is to retrieve mails. I tried over Imap - no success, (ImapX not connecting at all and no error is shown) and I came to EWS.
但是还涉及一些voo-doo魔术. 这是有一些错误的代码:
But there is also some voo-doo magic involved. And here is the code with some errors:
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.TraceEnabled = true;
service.TraceFlags = TraceFlags.All;
service.UseDefaultCredentials = true;
service.Url = new Uri("https://some.com/EWS/Exchange.asmx"); // The request failed. Unable to connect to the remote server
var folder = Folder.Bind(service, WellKnownFolderName.Inbox);
///////////////////another try
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.TraceEnabled = true;
service.TraceFlags = TraceFlags.All;
service.UseDefaultCredentials = true;
service.AutodiscoverUrl("someone@some.com"); // Discover server not found
var folder = Folder.Bind(service, WellKnownFolderName.Inbox);
但是,我可以连接到wsdl版本:
However, I'm able to connect to wsdl version:
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.TraceEnabled = true;
service.TraceFlags = TraceFlags.All;
service.UseDefaultCredentials = true;
service.Url = new Uri("https://some.com:444/EWS/Services.wsdl");//Wow! It worked.
var folder = Folder.Bind(service, WellKnownFolderName.Inbox);//duh, Method Not Allowed ........
return null;
我该如何连接到EWS?我能够通过Outlook连接,并从我的域帐户的Autodiscover.xml文件中获取了所有这些地址.这个问题让我震惊.
How the heck do I connect to EWS? I'm able to connect through Outlook, and aquired all this addresses from its Autodiscover.xml file of my domain account. This question blowing my head.
更新
以下是IMAP服务器的示例:
Here is example with IMAP server:
var client = new ImapX.ImapClient("imap.some.com", 993, true);
client.Connect(); //just do nothing. nothing is connected, no errors.
推荐答案
请确保已为EWS Web服务配置了自动分发服务.使用Microsoft测试连接工具来分析交换发现设置:
Make sure you have autodisocver configure for EWS webservices. Use the microsoft test connectivity tool to analyze the exchange discovery settings:
https://testconnectivity.microsoft.com/
这篇关于如何连接到Exchange?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!