使用 Outlook REST 获取没有 ContentBytes 的 ContentId(或任何 FileAttachment 属性)API
Get ContentId (or any FileAttachment properties) without ContentBytes with Outlook REST API
在我使用 Outlook REST API 的应用程序中,为了支持 html 电子邮件中的内联图像,我需要检索 File Attachments 的 ContentId
给定电子邮件。
注意: 在 html 电子邮件内嵌图像是 html 形式的标签 <input scr="cid:mycontentid">
我设法在 url https://outlook.office.com/api/v2.0/me/messages/{message_id}/attachments
获得了这些信息
问题是返回的 json 还包含 ContentBytes
,对于大型附件可以任意大。
我尝试了几种语法来只检索我需要的字段,例如:
https://outlook.office.com/api/v2.0/me/messages/{message_id}/attachments?$select=Id,ContentId
或 '$select=Id&$expand=ContentId'
none 成功了,导致错误请求
{"error":{"code":"RequestBroker-ParseUri","message":"Could not find a property named 'ContentId' on type 'Microsoft.OutlookServices.Attachment'."}}
url '/attachments'
的预期类型是 Microsoft.OutlookServices.Attachment
,它是 File Attachments 和项目附件的基本类型。
我想检索文件附件的特定成员 (ContentId
) 或丢弃结果中包含的重 ContentBytes
。
me/messages/{message_id}/attachments
return附件集合的端点。
ContentId 是 FileAttachment 的 属性。您可以使用下面的代码获取 fileAttachment:
的 contentId
GET: https://outlook.office.com/api/v2.0/me/messages/{messageId}/attachments?$select=Microsoft.OutlookServices.FileAttachment/ContentId
编辑:
备注:如果要检索其他字段,请说Name
注意$select=Microsoft.OutlookServices.FileAttachment/ContentId,Name
会起作用,而$select=Name,Microsoft.OutlookServices.FileAttachment/ContentId
会抛出原文中提到的错误问题
在我使用 Outlook REST API 的应用程序中,为了支持 html 电子邮件中的内联图像,我需要检索 File Attachments 的 ContentId
给定电子邮件。
注意: 在 html 电子邮件内嵌图像是 html 形式的标签 <input scr="cid:mycontentid">
我设法在 url https://outlook.office.com/api/v2.0/me/messages/{message_id}/attachments
问题是返回的 json 还包含 ContentBytes
,对于大型附件可以任意大。
我尝试了几种语法来只检索我需要的字段,例如:
https://outlook.office.com/api/v2.0/me/messages/{message_id}/attachments?$select=Id,ContentId
或 '$select=Id&$expand=ContentId'
none 成功了,导致错误请求
{"error":{"code":"RequestBroker-ParseUri","message":"Could not find a property named 'ContentId' on type 'Microsoft.OutlookServices.Attachment'."}}
url '/attachments'
的预期类型是 Microsoft.OutlookServices.Attachment
,它是 File Attachments 和项目附件的基本类型。
我想检索文件附件的特定成员 (ContentId
) 或丢弃结果中包含的重 ContentBytes
。
me/messages/{message_id}/attachments
return附件集合的端点。
ContentId 是 FileAttachment 的 属性。您可以使用下面的代码获取 fileAttachment:
的 contentIdGET: https://outlook.office.com/api/v2.0/me/messages/{messageId}/attachments?$select=Microsoft.OutlookServices.FileAttachment/ContentId
编辑:
备注:如果要检索其他字段,请说Name
注意$select=Microsoft.OutlookServices.FileAttachment/ContentId,Name
会起作用,而$select=Name,Microsoft.OutlookServices.FileAttachment/ContentId
会抛出原文中提到的错误问题