Microsoft Graph API组合$filter与$search查询邮件问题求助
正确的Microsoft Graph API查询语句
要同时筛选发件人邮箱和检索含特定关键词的邮件,以下两种方式均可正常运行:
方法1:整合条件到$search参数(推荐)
利用Graph API的搜索限定符from:,将发件人和关键词条件合并在$search中,语法更简洁且不易出错:
https://graph.microsoft.com/v1.0/me/messages?$search="get" AND from:member_services@outlook.com
- 关键词需用双引号包裹,
AND用于连接多个搜索条件 - 此查询会返回**包含关键词"get"且来自
member_services@outlook.com**的邮件
方法2:同时使用$filter和$search参数
若要保留两个独立参数,需修正$search的格式(给关键词加双引号),正确语句如下:
https://graph.microsoft.com/v1.0/me/messages?$filter=(from/emailAddress/address) eq 'member_services@outlook.com'&$search="get"
原组合报错的原因
你之前的请求报错,是因为$search参数中的关键词未用双引号包裹。Graph API要求$search的搜索词必须以双引号括起(尤其是在和$filter组合使用时),否则会触发语法解析错误。
另外注意:使用$search需要Exchange Online邮箱启用全文搜索(默认已开启),该参数仅支持部分邮件属性的搜索。
内容的提问来源于stack exchange,提问作者Sai T
相关产品推荐
相关产品推荐

