簡體   English   中英

Microsoft Graph SDK 消息過濾器未獲得正確結果

[英]Microsoft Graph SDK Message Fiter Not Getting Correct Result

我正在嘗試從me/messages獲取toRecipients 我得到正確的結果。 這是結果。

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('a803fa7d-d3b5-4065-882c-e9df1ca6a093')/messages(toRecipients)",
    "@odata.nextLink": "https://graph.microsoft.com/v1.0/me/messages?o=json&$select=toRecipients&$skip=10",
    "value": [
        {
            "@odata.etag": "W/\"CQAAABYAAAB6+NCu/3QGSbvxDC/F5lT6AAAaysW0\"",
            "id": "AAMkADZjNjAxZjY2LWNiNDQtNDQyMS05Y2Y3LTY3YTM5",
            "toRecipients": [
                {
                    "emailAddress": {
                        "name": "MyAnalytics",
                        "address": "no-reply@microsoft.com"
                    }
                }
            ]
        },
        
        {
            "@odata.etag": "W/\"CQAAABYAAAB6+NCu/3QGSbvxDC/F5lT6AAAaytNp\"",
            "id": "AAMkADZjNjAxZjY2LWNiNDQtNDQyMS05",
            "toRecipients": [
                {
                    "emailAddress": {
                        "name": "Test Email",
                        "address": "test@email.com"
                    }
                }
            ]
        },
        
        {
            "@odata.etag": "W/\"CQAAABYAAAB6+NCu/3QGSbvxDC/F5lT6AAAaysWw\"",
            "id": "AAMkADZjNjAxZ-FAAA=",
            "toRecipients": [
                {
                    "emailAddress": {
                        "name": "MyAnalytics",
                        "address": "no-reply@microsoft.com"
                    }
                }
            ]
        }
    ]
}

但是當我嘗試用條件filter時,結果它不起作用。 我要過濾的是“MyAnalytics”。 我想設置條件,其中toRecipients emailAddress name不等於MyAnalytics這是我的代碼

            GraphServiceClient graphClient = new GraphServiceClient(authProvider);
            SecureString pass = new NetworkCredential("", "myPass").SecurePassword;
            var messages = graphClient.Me.Messages.Request()
                  .Select(mail => new
                  {
                      mail.ToRecipients
                  })
            .Top(3)
            .Filter($"ToRecipients.emailAddress.name ne 'MyAnalytics'")
            .WithUsernamePassword("myEmail", pass).GetAsync().Result;

Note:基本上我想要前 3 個toRecipients ,其中emailAddress name不等於MyAnalyticsaddress不等於 'no-reply@microsoft.com'

任何幫助將不勝感激。

通常我們應該使用https://graph.microsoft.com/v1.0/me/messages?$filter=toRecipients/any(c:c/emailAddress/name ne 'MyAnalytics')

但事實上,根據我的測試,屬性toRecipients是不可過濾的。 這里有一個類似的答案供您參考。

由於您想排除電子郵件,因此不能選擇使用search

恐怕我們必須先獲得結果,然后通過在我們自己的代碼邏輯中檢查emailAddress/name來排除這些電子郵件。

暫無
暫無

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

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