简体   繁体   English

使用搜索 Microsoft Graph API C#

[英]Use search Microsoft Graph API C#

I am trying to filter the ToReceipient using Graph API in C#.我正在尝试使用 C# 中的 Graph API 过滤 ToReceipient。

as per Unable to filter messages by recipient in Microsoft Graph Api.根据无法在 Microsoft Graph Api 中按收件人过滤消息。 One or more invalid nodes 一个或多个无效节点

at the moment Filter does not support ToRecipient.目前过滤器不支持 ToRecipient。 I need to use Search.我需要使用搜索。

However in c# as per screenshot and code below, it does not seem to have search property, only filter.但是,根据下面的屏幕截图和代码,在 c# 中,它似乎没有搜索属性,只有过滤器。 Anyone knows how to use Search in Graph API c#?任何人都知道如何在 Graph API c# 中使用搜索? I also need to filter it based on multiple toRecipient Email addresses.我还需要根据多个 toRecipient 电子邮件地址对其进行过滤。 Thanks.谢谢。

IUserMessagesCollectionPage msgs = await client.Users["user@domain.com"].Messages.Request().Filter ==> exist

IUserMessagesCollectionPage msgs = await client.Users["user@domain.com"].Messages.Request().Search ==> does not exist

在此处输入图片说明

You can try using QueryOptions class as below.您可以尝试使用 QueryOptions 类,如下所示。

List<QueryOption> options = new List<QueryOption> 
{            
    new QueryOption("$search", "lunch") 
}; 

var messages = await client.Users["user@domain.com"].Messages.Request(options).GetAsync();

You can also use filter, top and other query parameters as well.您还可以使用 filter、top 和其他查询参数。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM