1

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 から直接取得すると、少し途方に暮れます。

乾杯、ダニエル。

4

1 に答える 1

0

気にしないで、修正してください-私のサービスを次のように指定する必要があります:

https://servername/ews/Exchange.asmx

接続するには、「ユーザー名」、「パスワード」などの通常のドメインログインの詳細を入力してください。

于 2010-11-12T17:23:09.740 に答える