【问题标题】:Graph API not returning file extension for MSG files图形 API 未返回 MSG 文件的文件扩展名
【发布时间】:2021-10-24 13:53:36
【问题描述】:

我正在使用以下 Graph API URL 来检索附加到电子邮件的文件名:

https://graph.microsoft.com/v1.0/me/messages/*/attachments

但是,它不再返回“.msg”文件的附加文件名。缺少文件扩展名。请看下面的示例返回:

{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('')/messages('')/attachments",
"value": [
{
"@odata.type": "#microsoft.graph.itemAttachment",
"id": "*",
"lastModifiedDateTime": "2021-08-13T11:21:29Z",
"name": "Original Email",
"contentType": null,
"size": 45795,
"isInline": false
}
]
}

其他文件类型的情况:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('')/messages('')/attachments",
"value": [
{
"@odata.type": "#microsoft.graph.fileAttachment",
"@odata.mediaContentType": "application/octet-stream",
"id": "",
"lastModifiedDateTime": "2021-08-13T11:14:07Z",
"name": "Original Email.mht",
"contentType": "application/octet-stream",
"size": 54693,
"isInline": false,
"contentId": null,
"contentLocation": null,
"contentBytes": ""
}
]
}

注意:敏感信息已被编辑 (*)。

我可以看到 @odata.type 的返回方式不同:

@odata.type": "#microsoft.graph.itemAttachment
@odata.type": "#microsoft.graph.fileAttachment

我不知道这是为什么,电子邮件以相同的方式附加。

在上述两种情况下,我使用 Outlook 给自己发送了一封电子邮件,将其保存到我的本地文件系统,创建了另一封电子邮件,附加了之前保存的文件,然后向自己发送了附有保存的电子邮件的新电子邮件。然后使用指定的 URL(以及许多其他变体)发出请求。

我查看了所有内容,我使用的请求 URL 没有返回此类型的文件扩展名。

有没有办法返回“.msg”文件的文件名?

【问题讨论】:

    标签: microsoft-graph-api microsoft-graph-mail


    【解决方案1】:

    MS 图区分资源级别的附件,即fileAttachment resource typeitemAttachment resource type

    即使以相同的方式附加,联系人、事件或消息附件属于itemAttachment resource type,并且与文件附件具有不同的道具。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-24
      • 1970-01-01
      • 2012-09-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多