簡體   English   中英

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

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

我試圖編寫一個簡單的示例程序來檢查Exchange 2010服務器上是否有新郵件。 據我所知,我擁有的代碼應該可以正常工作。

我將服務設置如下:

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

            }
        }

我收到此錯誤(在FindItemResults行上):

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

這似乎是API實際生成的XML中的錯誤,我嘗試了一些不同的代碼(沿同一行),但未找到任何有效的方法。

有任何想法嗎? 直接來自API時會有些茫然!

干杯,丹尼爾。

沒關系,已修復-需要將我的服務指向:

https://服務器名稱/ews/Exchange.asmx

並提供常規的域登錄詳細信息,例如“用戶名”,“密碼”以進行連接!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM