【问题标题】:If it is possible to search mailFolder using msgraph API by mailFolder displayName如果可以通过 mailFolder displayName 使用 msgraph API 搜索 mailFolder
【发布时间】:2022-09-29 05:05:50
【问题描述】:

我想实现一些功能以允许用户使用 msGraph API 搜索 mailFolder

如果可以通过 mailFolder 使用 msgraph API 搜索 mailFolder显示名称在文档中,我没有找到有关如何搜索 mailFolder 的任何提及。它仅显示如何通过 ID 获取 mailFolder。我们甚至可以搜索mailFolder吗?或者 mailFolders 不支持搜索? 感谢您的任何回答或建议

    标签: azure microsoft-graph-api graph-api-explorer


    【解决方案1】:

    您可以使用$filter 查询参数并搜索匹配displayName 的文件夹

    GET https://graph.microsoft.com/v1.0/me/mailFolders?$filter=displayName eq 'name'
    

    或者如果displayName 以某个值开头

    GET https://graph.microsoft.com/v1.0/me/mailFolders?$filter=startswith(displayName,'name')
    

    资源:

    Filter parameter

    【讨论】:

    • 感谢您的回答,但它只过滤根邮件文件夹。我需要在整个邮箱中进行搜索
    【解决方案2】:

    是的,这是可能的——分两步。

    首先,获取邮箱的所有邮件文件夹(根文件夹和子文件夹):

    https://graph.microsoft.com/v1.0/users/<[ID] or UPN of mailbox>/mailFolders/delta
    

    这为您提供了一个包含所有邮件文件夹的数组。就我而言,我将它们存储在 $MailFolders (Powershell)

    其次,仅从数组中获取具有所需 displayName 的那个。

    例如,在 Powershell 中,我这样做:

    $Mailfolder = $MailFolders | where displayName -eq "<displayName of desired folder>"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-29
      • 1970-01-01
      • 2019-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-05
      相关资源
      最近更新 更多