Win2012 Server R2上的API ExchangeWebService v2.2错误

时间:2016-01-06 02:58:20

标签: c# exchangewebservices

我正在创建一个解析电子邮件然后回复发件人的软件,无论电子邮件是否有效。

在我的开发机器(Win8.1)中,一切都很好,然后我创建了一个exe来在我们在Windows Server 2012 R2 Standard上运行的服务器上测试它。

令我惊讶的是,它犯了一个错误。

我尝试更改ff,但似乎没有任何效果:

service = new ExchangeService(ExchangeVersion.Exchange2010)
service = new ExchangeService(ExchangeVersion.Exchange2013_SP1)
service = new ExchangeService(ExchangeVersion.Exchange2010_SP2)

这是否意味着EWS与Win2012 Server R2不兼容?

TIA

**** **** UPDATE 由于Im在服务器中运行时只有错误,我怀疑我的错误来自此代码:

    FindItemsResults<Item> findResults = service.FindItems(
       WellKnownFolderName.Inbox,
       new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false)),
       new ItemView(int.MaxValue));

我如何初始化EWS:

ExchangeService service;
            service = new ExchangeService(ExchangeVersion.Exchange2010)
            {
                Credentials = new WebCredentials(EmailAddress, EmailPassword, Domain),
                UseDefaultCredentials = false,
                TraceEnabled = true,
                Url = new Uri(EmailHostServerURL)
            };

错误:

Microsoft.Exchange.WebServices.Data.ServiceVersionException: Exchange Server doesn't support the requested version.
   at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ProcessWebException(WebException webException)
   at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request)
   at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(IEwsHttpWebRequest& request)
   at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
   at Microsoft.Exchange.WebServices.Data.ExchangeService.FindItems[TItem](IEnumerable`1 parentFolderIds, SearchFilter searchFilter, String queryString, ViewBase view, Grouping groupBy, ServiceErrorHandling errorHandlingMode)
   at Microsoft.Exchange.WebServices.Data.ExchangeService.FindItems(FolderId parentFolderId, SearchFilter searchFilter, ViewBase view)
   at Microsoft.Exchange.WebServices.Data.ExchangeService.FindItems(WellKnownFolderName parentFolderName, SearchFilter searchFilter, ViewBase view)

更新2

在知道我们的Exchange是Exchange 2010之后,我将其更改为了。现在这是我的错误...

Microsoft.Exchange.WebServices.Data.ServiceRequestException: The request failed. The remote server returned an error: (401) Unauthorized. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized. ---> System.ComponentModel.Win32Exception: The target principal name is incorrect
   at System.Net.NTAuthentication.GetOutgoingBlob(Byte[] incomingBlob, Boolean throwOnError, SecurityStatus& statusCode)
   at System.Net.NTAuthentication.GetOutgoingBlob(String incomingBlob)
   at System.Net.NegotiateClient.DoAuthenticate(String challenge, WebRequest webRequest, ICredentials credentials, Boolean preAuthenticate)
   at System.Net.NegotiateClient.Authenticate(String challenge, WebRequest webRequest, ICredentials credentials)
   at System.Net.AuthenticationManager.Authenticate(String challenge, WebRequest request, ICredentials credentials)
   at System.Net.AuthenticationState.AttemptAuthenticate(HttpWebRequest httpWebRequest, ICredentials authInfo)
   at System.Net.HttpWebRequest.CheckResubmitForAuth()
   at System.Net.HttpWebRequest.CheckResubmit(Exception& e, Boolean& disableUpload)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetResponse()
   at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.Emit(HttpWebRequest& request)
   at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(HttpWebRequest& request)
   --- End of inner exception stack trace ---
   at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(HttpWebRequest& request)
   at Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.InternalExecute()
   at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
   at Microsoft.Exchange.WebServices.Data.ExchangeService.FindItems[TItem](IEnumerable`1 parentFolderIds, SearchFilter searchFilter, String queryString, ViewBase view, Grouping groupBy, ServiceErrorHandling errorHandlingMode)
   at Microsoft.Exchange.WebServices.Data.ExchangeService.FindItems(FolderId parentFolderId, SearchFilter searchFilter, ItemView view)
   at Microsoft.Exchange.WebServices.Data.ExchangeService.FindItems(WellKnownFolderName parentFolderName, SearchFilter searchFilter, ItemView view)

问题2:

在搜索答案时,我看到了link。 这是否意味着无论我做什么,它都无法在Win2012 Server R2中运行?

0 个答案:

没有答案