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

Microsoft Graph API筛选Outlook收件箱sender地址返回空结果问题

问题:使用Microsoft Graph筛选Outlook指定发件人邮件返回空结果

我尝试用以下Python代码筛选Outlook收件箱中指定发件人的邮件:

sender_email = 'test@test.de'
filter_expression = f"sender/emailAddress/address eq '{sender_email}'"
url = f"https://graph.microsoft.com/v1.0/users/{user_principal_name}/mailFolders/Inbox/messages?$filter={filter_expression}&top=1000"

但收到了空响应:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('abc%40test.de')/mailFolders('Inbox')/messages",
    "value": []
}

不过当不使用筛选直接读取所有邮件时,能确认目标发件人的邮件确实存在于结果中:

...
    "subject": "Scanned images", 
...
    "sender": {
        "emailAddress": {
            "name": "Test User",
            "address": "test@test.de"
        }
    },
    "from": {
        "emailAddress": {
            "name": "Test User",
            "address": "test@test.de"
        }
    },
...

有趣的是,使用主题筛选时能得到正确的结果:

filter_expression = f"startswith(subject, 'Scanned')"

我的请求发送代码如下:

def graph_get(url, token):
    headers = {"Authorization": f"Bearer {token}"}
    r = requests.get(url, headers=headers)
    return r.json()

response = graph_get(url, token)

请问我在使用sender/emailAddress/address进行筛选时哪里出错了?有什么解决思路?


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.08 00:17:16