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

如何获取Outlook Webhook推送通知对应的目标邮箱地址?

获取Outlook推送通知对应的目标邮箱地址

推送通知的payload本身不会直接返回目标邮箱地址,你可以通过以下两种方法获取:

方法1:创建订阅时存入邮箱信息(推荐)

创建订阅时,利用clientState这个自定义字符串字段,把对应账户的邮箱地址或唯一标识存进去。比如创建订阅的请求示例:

{
  "changeType": "updated",
  "notificationUrl": "你的接收通知的URL",
  "resource": "/me/mailFolders('inbox')/messages",
  "clientState": "target-user@example.com", // 直接存入目标邮箱地址
  "expirationDateTime": "2024-12-31T00:00:00Z"
}

收到推送通知时,直接读取clientState字段的值即可拿到目标邮箱,无需额外调用API。

方法2:通过Microsoft Graph API从邮件资源反推邮箱

如果创建订阅时未设置clientState,可以借助payload里的字段调用API获取:

  1. 提取resourceData中的@odata.id值,格式通常为users/{userId}/messages/{messageId}
  2. 调用Graph API获取邮件详情:
    GET https://graph.microsoft.com/v1.0/users/{userId}/messages/{messageId}
    
  3. 从上述请求的路径中提取userId,再调用API获取用户信息:
    GET https://graph.microsoft.com/v1.0/users/{userId}
    
    返回结果里的mail字段就是目标邮箱地址。

你也可以通过邮件的parentFolderId关联到收件箱所属邮箱:

  • 调用GET https://graph.microsoft.com/v1.0/users/{userId}/mailFolders/{parentFolderId}
  • 确认该文件夹为收件箱后,同样通过userId调用用户信息API获取邮箱地址。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.23 07:52:09