我的目标是通过逻辑应用程序使用 msgraph api 查询共享邮箱并返回主题行中关键字的结果。
以上是我目前写的。
我想知道这个查询是否正确。
为了完成此任务,我可以授予身份验证应用程序注册或托管身份的最小特权角色是什么。理想情况下,我不想授予此应用程序注册/身份权限来读取指定邮箱以外的任何内容。
验证查询:
https://graph.microsoft.com/v1.0/users/@{items('For_each_5')}/messages?$filter=from/emailAddress/address eq '[email protected]' and toRecipients/any(r:r/emailAddress/address eq '@{items('For_each_5')}') and contains(subject, 'keyword')&$select=subject,from,toRecipients,receivedDateTime,bodyPreview
我认为使用
toRecipients
时不支持$filter
。我更喜欢使用$search
。查询将更具可读性
https://graph.microsoft.com/v1.0/users/@{items('For_each_5')}/messages?$search="from:[email protected] and to:@{items('For_each_5')} and subject:keyword"&$select=subject,from,toRecipients,receivedDateTime,bodyPreview
托管身份需要
Mail.Read
应用程序权限,但您可以限制对特定邮箱的访问。
https://learn.microsoft.com/en-us/graph/auth-limit-mailbox-access?view=graph-rest-1.0