【问题标题】:Microsoft Azure Graph API download itemAttachment contentMicrosoft Azure Graph API 下载项附件内容
【发布时间】:2017-07-01 19:33:21
【问题描述】:

当我在 office365 网络浏览器页面中打开电子邮件时,有一个选项可以下载此电子邮件 itemAttachment 的附件内容(使用 Microsoft Outlook 附加到当前邮件的另一封邮件)- * .eml 文件,(内容类型:RFC-822)。

但是,当我尝试通过 Graph API(相同的操作)获取此 itemAttachment 的内容时, contentBytes 响应属性不存在。

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#users('bbbbb')/messages('fffff')/attachments",
    "value": [{
            "@odata.type": "#microsoft.graph.itemAttachment",
            "id": "gggg",
            "lastModifiedDateTime": "2017-02-13T16:29:45Z",
            "name": "The Daily Build - Compiling your C code to .NET",
            "contentType": "message/rfc822",
            "size": 99129,
            "isInline": false
        }
    ]
}

任何想法如何通过 Graph API ( contentType=itemAttachment ) 获取附加的 Outlook 消息的内容? fileAttachment contentType 工作正常,我可以从 Graph API 响应的 contentBytes 属性中获取内容。考虑以下 API 端点:

https://graph.microsoft.com/beta/me/messages/{id}/附件

https://graph.microsoft.com/beta/me/messages/{id}/attachments/{attachmentId}

https://graph.microsoft.com/beta/me/messages/{id}/attachments/{attachmentId}?$expand=#microsoft.graph.itemAttachment/item

以上都不返回附加项目的内容。

【问题讨论】:

  • 暂不支持下载itemAttachment内容。我们现在正在评估它,当我有具体结果时我会发布更新。
  • @SriramDhanasekaran-MSFT 有什么更新吗?现在可以检索 itemAttachment 的内容吗?
  • 你试过我的答案了吗?
  • 是的,你是对的@RiccardoGDev,该功能仍在开发中,它在测试版(或预览版)中可用,但我不能对实时应用程序使用测试版或预览版。等待稳定版本。

标签: outlook office365 microsoft-graph-api


【解决方案1】:

它处于测试阶段,没有文档,但您可以使用 Microsoft Graph API 获取 MIME 内容:

GET https://graph.microsoft.com/beta/me/messages/{id}/$value

或

GET https://graph.microsoft.com/beta/users/{id | userPrincipalName}/messages/{id}/$value

附件:

GET https://graph.microsoft.com/beta/users/{id}/messages/{id}/attachments/{id}/$value

您可以使用响应创建一个扩展名为 .eml 的文件。

编辑:

现已正式预览:https://docs.microsoft.com/en-us/graph/outlook-get-mime-message

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-16
    • 1970-01-01
    • 2018-09-23
    • 2019-07-13
    相关资源
    最近更新 更多