C# Exchange EWS托管API-XML中的意外令牌

C# Exchange EWS托管API-XML中的意外令牌,c#,exchange-server,ews-managed-api,C#,Exchange Server,Ews Managed Api,我正在尝试编写一个简单的示例程序,用于检查Exchange2010服务器上的任何新邮件。据我所知,我得到的代码应该可以正常工作 我按如下方式设置服务: ExchangeService service = new ExchangeService(); service.Credentials = new WebCredentials("user@domain.co.uk", "password"); service.Url = new Uri("https://address/owa"); 在

我正在尝试编写一个简单的示例程序,用于检查Exchange2010服务器上的任何新邮件。据我所知,我得到的代码应该可以正常工作

我按如下方式设置服务:

ExchangeService service = new ExchangeService();

service.Credentials = new WebCredentials("user@domain.co.uk", "password");

service.Url = new Uri("https://address/owa");
在执行以下代码时:

        int unreadMail = 0;

        // Add a search filter that searches on the body or subject.
        List<SearchFilter> searchFilterCollection = new List<SearchFilter>();
        searchFilterCollection.Add(new SearchFilter.ContainsSubstring(ItemSchema.Subject, "Defense"));

        // Create the search filter.
        SearchFilter searchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.Or, searchFilterCollection.ToArray());

        // Create a view with a page size of 50.
        ItemView view = new ItemView(50);

        // Identify the Subject and DateTimeReceived properties to return.
        // Indicate that the base property will be the item identifier
        view.PropertySet = new PropertySet(BasePropertySet.IdOnly, ItemSchema.Subject, ItemSchema.DateTimeReceived);

        // Order the search results by the DateTimeReceived in descending order.
        view.OrderBy.Add(ItemSchema.DateTimeReceived, SortDirection.Descending);

        // Set the traversal to shallow. (Shallow is the default option; other options are Associated and SoftDeleted.)
        view.Traversal = ItemTraversal.Shallow;

        // Send the request to search the Inbox and get the results.
        FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, searchFilter, view);

        // Process each item.
        foreach (Item myItem in findResults.Items)
        {
            if (myItem is EmailMessage)
            {
                if (myItem.IsNew) unreadMail++;

            }
        }
这似乎是API实际生成的XML中的一个错误,我尝试了一些不同的代码(都是相同的代码),但没有找到任何有效的代码

有什么想法吗?当它直接来自API时,有点不知所措


干杯,丹尼尔。

没关系,修好了-需要将我的服务指向:

并提供常规域登录详细信息,如“用户名”、“密码”,以便连接

'>' is an unexpected token. The expected token is '"' or '''. Line 1, position 63.