我们可以借助 Microsoft Graph API 来检索 Outlook 邮件消息。具体步骤如下:
示例代码:
import requests
access_token = "ENTER_YOUR_ACCESS_TOKEN_HERE"
start_datetime = "2021-05-31T00:00:00Z" end_datetime = "2021-06-01T00:00:00Z"
response = requests.get( "https://graph.microsoft.com/v1.0/me/messages?$filter=receivedDateTime ge {0} and receivedDateTime le {1}".format(start_datetime, end_datetime), headers={ "Authorization": "Bearer "+access_token } )
print(response.json())
注意:在代码示例中,我们使用了 requests 库来发送 GET 请求。同时,我们还需要先使用 OAuth 2.0 来获取访问令牌,这里不作详细说明。此外,我们还可以根据自己的需求来定制 $select 参数来选择需要返回的字段。
上一篇:按时间范围将文件筛选到单个表中