简体   繁体   English

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

[英]Exchange EWS Managed API - unexpected token in XML

Im trying to write a simple sample program which checks for any new mail on an Exchange 2010 server. 我试图编写一个简单的示例程序来检查Exchange 2010服务器上是否有新邮件。 As far as I can tell, the code I've got should work fine. 据我所知,我拥有的代码应该可以正常工作。

I setup the service as follows: 我将服务设置如下:

ExchangeService service = new ExchangeService();

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

service.Url = new Uri("https://address/owa");

Upon executing the following code: 执行以下代码后:

        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++;

            }
        }

I get this error (on the FindItemResults line): 我收到此错误(在FindItemResults行上):

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

This appears to be an error in the XML the API is actually generating, I've tried a few different lots of code (all along the same lines) and not found anything that works. 这似乎是API实际生成的XML中的错误,我尝试了一些不同的代码(沿同一行),但未找到任何有效的方法。

Any ideas? 有任何想法吗? At a bit of a loss when it comes directly from the API! 直接来自API时会有些茫然!

Cheers, Daniel. 干杯,丹尼尔。

Nevermind, fixed it - needed to point my service to: 没关系,已修复-需要将我的服务指向:

https://servername/ews/Exchange.asmx https://服务器名称/ews/Exchange.asmx

and provide regular domain login details such as "username", "password" in order to connect! 并提供常规的域登录详细信息,例如“用户名”,“密码”以进行连接!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 按日期获取Exchange EWS托管API 2.0 - Exchange EWS Managed API 2.0 get by date 通过 EWS 托管 API 与 Exchange Online 交谈时刷新访问令牌 - Refresh access token when talking to Exchange Online via EWS Managed API 使用EWS托管API将.msg文件上传到Exchange Server - Upload .msg file to Exchange Server using EWS Managed API Exchange ews托管api在公用文件夹中创建项目 - Exchange ews managed api create item in public folder 如何使用 Exchange Online/EWS 托管 API 对控制台应用程序进行身份验证? - How to authenticate a console application with Exchange Online/EWS Managed API? 允许模拟用户通过EWS托管API 2.0登录到Exchange Server - Allow impersonation users to login to Exchange Server by EWS Managed API 2.0 使用EWS托管API访问Exchange(2016)审核日志 - Access Exchange (2016) audit logs with EWS Managed API EWS托管API和Exchange 2013中的Folder.WellKnownFolderName为空 - Folder.WellKnownFolderName is null in EWS Managed API and Exchange 2013 使用EWS托管API访问共享的联系人(Exchange 2010) - Accessing Shared Contacts with EWS Managed API (Exchange 2010) 在某些属性上更新EmailMessage时发生Exchange EWS托管API错误 - Exchange EWS Managed API Error while Updating EmailMessage on certain properties
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM