You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Microsoft Graph API中基于ccRecipients、bccRecipients、toRecipients筛选邮件

问题根因

你的$filter筛选语法不符合Microsoft Graph OData查询规范:toRecipients、ccRecipients、bccRecipients都是recipient对象集合,每个对象下的emailAddress属性还有二级address字段存储实际邮箱地址,你之前的写法跳过了对address字段的访问,所以触发无效筛选子句错误。

可行解决方案

1. 仅筛选收件人(toRecipients)包含指定邮箱的请求示例

https://graph.microsoft.com/v1.0/users/{{UserId}}/messages?$filter=receivedDateTime ge 2021-09-01 and receivedDateTime lt 2021-12-15 and toRecipients/any(r: r/emailAddress/address eq 'something@email.com')

2. 同时筛选to/cc/bcc任意字段包含指定邮箱的请求示例

如果需要匹配三个收件人字段中任意一个存在目标邮箱,用or拼接三个筛选条件即可:

https://graph.microsoft.com/v1.0/users/{{UserId}}/messages?$filter=receivedDateTime ge 2021-09-01 and receivedDateTime lt 2021-12-15 and (toRecipients/any(r: r/emailAddress/address eq 'something@email.com') or ccRecipients/any(r: r/emailAddress/address eq 'something@email.com') or bccRecipients/any(r: r/emailAddress/address eq 'something@email.com'))
注意事项
  • 请确保你的应用已申请Mail.Read或更高的邮件读取接口权限,否则会返回权限类错误
  • 默认邮箱匹配不区分大小写,符合邮箱地址的通用使用规则
  • 单次查询的时间范围建议不要超过180天,避免接口返回查询超时或结果截断

内容的提问来源于stack exchange,提问作者Sadashiv

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.28 03:36:01