具有限制的EWS FindItem适用于Exchange 2007,而不适用于2010 [英] EWS FindItem with restriction works in Exchange 2007, not in 2010

查看:62
本文介绍了具有限制的EWS FindItem适用于Exchange 2007,而不适用于2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VB.net中写了一个应用程序,它适用于Exchange 2007,但是在针对2010服务器运行时失败。 具体来说,我要做的是基于开始日期和结束日期的限制(搜索)。 这是
代码的一部分:

I have an application writtten in VB.net and it works with Exchange 2007, but when run against a 2010 server fails.  Specifically, what I'm trying to do is a restriction (search) based on start date and end date.  Here is part of the code:


              StartDateReceivedToGet.Value = EndDate.ToUniversalTime().ToString()

               Debug.Print(Now() & ": Start date UTC: " & EndDate.ToUniversalTime().ToString())

              Dim StartDateReceivedConstant As New FieldURIOrConstantType()
              StartDateReceivedConstant.Item = StartDateReceivedToGet

              Dim igtett As New IsGreaterThanOrEqualToType()
              igtett.FieldURIOrConstant = StartDateReceivedConstant
              igtett.Item = StartDateReceivedField

              'restrict the returned items less than a specified date
              Dim EndDateReceivedField As New PathToUnindexedFieldType()
              EndDateReceivedField.FieldURI = UnindexedFieldURIType.itemDateTimeReceived

              Dim EndDateReceivedToGet As New ConstantValueType()
              EndDateReceivedToGet.Value = StartDate.ToUniversalTime().ToString()

              If LogLevel > 0 Then
                ThreadLogFile.WriteLine(Now() & ": End date UTC: " & StartDate.ToUniversalTime().ToString())
                If LogLevel > 1 Then
                  LogFile.WriteLine(Now() & ": End date UTC: " & StartDate.ToUniversalTime().ToString())
                End If
              End If

              Debug.Print(Now() & ": End date UTC: " & StartDate.ToUniversalTime().ToString())

              Dim EndDateReceivedConstant As New FieldURIOrConstantType()
              EndDateReceivedConstant.Item = EndDateReceivedToGet

              Dim iltett As New IsLessThanOrEqualToType()
              iltett.FieldURIOrConstant = EndDateReceivedConstant
              iltett.Item = EndDateReceivedField

              Dim at As New AndType()
              at.Items = New SearchExpressionType(2) {}
              at.Items(0) = igtett
              at.Items(1) = iltett

              ' Create a restriction type
              Dim restriction As New RestrictionType()

              ' Add the search expression to the restriction.
              restriction.Item = at

              ' Add the restriction criteria to the findItem request.
              ' findItemRequest.Restriction = restriction

              'Find the messages within the specified date range

              Dim FIAttempts As Integer

              Try

FindItems:
 
                Dim firt As FindItemResponseType = esb.FindItem(findItemRequest)

                For Each firmtMessage As FindItemResponseMessageType In firt.ResponseMessages.Items

                  Debug.Print("Number of messages found for folder " & Folder.DisplayName & ": " & firmtMessage.RootFolder.TotalItemsInView.ToString)

推荐答案

我遇到了同样的问题但我找到了一个适合我的解决方案。尝试格式化您的日期,如EndDate.ToUniversalTime()。ToString(" yyyy-MM-ddTHH:mm:ssZ")。早些时候我的日期格式是"yyyy-MM-dd HH:mm:ss"。它在Exchange 2007上工作了
,但不是2010年。现在它适用于两个版本。

I had the same kind of problem but I've found a solution that works form me. Try to format Your date like this EndDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"). Earlier my date format was "yyyy-MM-dd HH:mm:ss" and it worked on Exchange 2007, but not 2010. Now It works on both versions.


这篇关于具有限制的EWS FindItem适用于Exchange 2007,而不适用于2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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