[英]Microsoft graph API how to query mails sent to specific address
我想使用 此处的文档查询我的 outlook 消息以获取我发送邮件的特定地址,我能够构建下面的查询。 但是,它返回 400 错误代码,我不知道如何继续。
https://graph.microsoft.com/v1.0/Users/{user}/messages/?$filter=toRecipients/any(t:t/emailAddress/address eq '{target_email}')
作为参考,这是消息的结构方式:
url = https://graph.microsoft.com/v1.0/Users/{user}/messages/?$filter=from/emailAddress/address eq 'john@testdomain.com'
messages = requests.get(url, headers=headers)
message = r['value'][0]
print(message['from'])
print(message['toRecipients'])
{'emailAddress': {'name': 'john', 'address': 'john@testdomain.com'}}
[{'emailAddress': {'name': 'sara', 'address': 'sara@testdomain.com'}}]
我的想法是过滤 toRecipients,遍历所有收件人并在给定的 emailAdress 中查找匹配项。 我应该如何以正确的方式做到这一点?
toRecipients 与发件人地址的工作方式不同,因为一个只是 microsoft.graph.emailaddress 类型的属性,另一个是这些属性的集合(从技术上讲,这是交换中收件人集合的一部分,其中还包括 CC 对象所以它是一个嵌套集合)。
这些属性已编入索引,因此您可以使用搜索来查找消息,例如
/me/messages?$search="to:blah@blah.com"&$select=subject,toRecipients
或者您可以使用包括 from,to,cc 的参与者
/me/messages?$search="participants:blah@blah.com"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.