gpt4 book ai didi

c# - Microsoft Graph SDK 消息筛选器未获得正确的结果

转载 作者:行者123 更新时间:2023-12-03 02:32:11 33 4
gpt4 key购买 nike

我正在尝试从 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": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c2acadefb0a7b2aebb82afaba1b0adb1ada4b6eca1adaf" rel="noreferrer noopener nofollow">[email protected]</a>"
}
}
]
},

{
"@odata.etag": "W/\"CQAAABYAAAB6+NCu/3QGSbvxDC/F5lT6AAAaytNp\"",
"id": "AAMkADZjNjAxZjY2LWNiNDQtNDQyMS05",
"toRecipients": [
{
"emailAddress": {
"name": "Test Email",
"address": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bbcfdec8cffbded6dad2d795d8d4d6" rel="noreferrer noopener nofollow">[email protected]</a>"
}
}
]
},

{
"@odata.etag": "W/\"CQAAABYAAAB6+NCu/3QGSbvxDC/F5lT6AAAaysWw\"",
"id": "AAMkADZjNjAxZ-FAAA=",
"toRecipients": [
{
"emailAddress": {
"name": "MyAnalytics",
"address": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cca2a3e1bea9bca0b58ca1a5afbea3bfa3aab8e2afa3a1" rel="noreferrer noopener nofollow">[email protected]</a>"
}
}
]
}
]
}

但是当我尝试使用条件过滤时,结果它不起作用。我试图过滤的是“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;

注意: 基本上我想要前 3 个 toRecipients,其中 emailAddress name 不是等于 MyAnalyticsaddress 不等于 ' [email protected] '

任何帮助将不胜感激。

最佳答案

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

但事实上,根据我的测试,属性 toRecipients 是不可过滤的。类似的答案here供您引用。

由于您想排除电子邮件,因此不能使用搜索

恐怕我们必须先获取结果,然后通过在我们自己的代码逻辑中检查 emailAddress/name 来排除这些电子邮件。

关于c# - Microsoft Graph SDK 消息筛选器未获得正确的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64658635/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com