gpt4 book ai didi

rest - 通过 Office 365 REST API 标记消息?

转载 作者:行者123 更新时间:2023-12-04 08:06:23 27 4
gpt4 key购买 nike

我正在寻找一种方法来使用 Office 365 REST 消息 API 检测和设置电子邮件的“已标记”状态。我没有看到“标志”列为 REST Message 的属性, 虽然我确实看到它列在 Exchange Web Services 下.

我尝试进行 REST 调用,将 Flag 添加到过滤属性,以及 SingleValueExtendedProperties 和 MultiValueExtendedProperties,例如:

/folders/inbox/messages?$top=50&$select=Subject,...,Flag
/folders/inbox/messages?$top=50&$select=Subject,...,SingleValueExtendedProperties
/folders/inbox/messages?$top=50&$select=Subject,...,MultiValueExtendedProperties

所有这些都以某种形式返回:

{"error":{"code":"RequestBroker-ParseUri","message":"Could not find a property named \\\'Flag\\\' on type \\\'Microsoft.OutlookServices.Message\\\'."}}

关于如何通过 REST API 访问 Outlook“标志”属性的任何建议?

最佳答案

更新:/beta 端点上的Message 现在有一个Flag 属性。这是执行此操作的推荐方法。我将保留其他信息以供历史引用,并帮助人们尝试设置其他扩展属性。

现在您可以更轻松地获取/设置标志状态。 Message entity现在有 FollowupFlag 类型的 Flag 属性。 (如果您在该链接中没有看到它,请确保在页面顶部选择了 beta 版本)。

您可以通过发送具有以下有效负载的 PATCH 将消息标记为已标记:

{
"Flag": {
"FlagStatus": "Flagged"
}
}

旧方法(使用扩展属性)

Note: We recently made a change to simplify the extended properties format. This change is rolling out to servers now, so I've added the new format to this answer. I've left the old format in case anyone is accessing mailboxes that haven't had the update applied yet. If using the old format and you get an error:

"Could not find a property named 'PropertyRef' on type 
'Microsoft.OutlookServices.SingleValueLegacyExtendedProperty'."

You need to move to the new format.

您需要做的是包含一个 $expand 查询参数来扩展 SingleValueExtendedProperties 集合,并包含一个 $filter 子参数来指明您要包括的属性。在这种情况下,您需要 PidTagFlagStatus .尝试这样的查询:

新格式:

api/beta/me/messages?$select=Subject,SingleValueExtendedProperties&$expand=SingleValueExtendedProperties($filter=PropertyId eq 'Integer 0x1090')

旧格式:

api/beta/me/messages?$select=Subject,SingleValueExtendedProperties&$expand=SingleValueExtendedProperties($filter=(PropertyRef eq '0x1090' and Type eq Microsoft.OutlookServices.MapiPropertyType'Integer'))

根本没有标记的消息将不会返回该属性。执行的消息看起来像这样:

新格式:

{
"@odata.id": "https://outlook.office365.com/api/beta/Users('JasonJ@jasonjohdemo.onmicrosoft.com')/Messages('AAMkAGQ4Yzc2NDkwLTYxYmItNDZmYS1iZjI1LTYyNmY4NTZkMjI1NgBGAAAAAADwPSus7EwaR6q1wNtgoqEMBwDpfBfj8UPUTqu4bEwGpnFMAAAAAAEgAADpfBfj8UPUTqu4bEwGpnFMAAAjCUJGAAA=')",
"@odata.etag": "W/\"CQAAABYAAADpfBfj8UPUTqu4bEwGpnFMAAAjCzND\"",
"Id": "AAMkAGQ4Yzc2NDkwLTYxYmItNDZmYS1iZjI1LTYyNmY4NTZkMjI1NgBGAAAAAADwPSus7EwaR6q1wNtgoqEMBwDpfBfj8UPUTqu4bEwGpnFMAAAAAAEgAADpfBfj8UPUTqu4bEwGpnFMAAAjCUJGAAA=",
"Subject": "Test Flag",
"SingleValueExtendedProperties@odata.context": "https://outlook.office365.com/api/beta/$metadata#Me/Messages('AAMkAGQ4Yzc2NDkwLTYxYmItNDZmYS1iZjI1LTYyNmY4NTZkMjI1NgBGAAAAAADwPSus7EwaR6q1wNtgoqEMBwDpfBfj8UPUTqu4bEwGpnFMAAAAAAEgAADpfBfj8UPUTqu4bEwGpnFMAAAjCUJGAAA%3D')/SingleValueExtendedProperties",
"SingleValueExtendedProperties": [
{
"PropertyId": "Integer 0x1090",
"Value": "2"
}
]
}

旧格式:

{
"@odata.id": "https://outlook.office365.com/api/beta/Users('JasonJ@jasonjohdemo.onmicrosoft.com')/Messages('AAMkAGQ4Yzc2NDkwLTYxYmItNDZmYS1iZjI1LTYyNmY4NTZkMjI1NgBGAAAAAADwPSus7EwaR6q1wNtgoqEMBwDpfBfj8UPUTqu4bEwGpnFMAAAAAAEgAADpfBfj8UPUTqu4bEwGpnFMAAAjCUJGAAA=')",
"@odata.etag": "W/\"CQAAABYAAADpfBfj8UPUTqu4bEwGpnFMAAAjCzND\"",
"Id": "AAMkAGQ4Yzc2NDkwLTYxYmItNDZmYS1iZjI1LTYyNmY4NTZkMjI1NgBGAAAAAADwPSus7EwaR6q1wNtgoqEMBwDpfBfj8UPUTqu4bEwGpnFMAAAAAAEgAADpfBfj8UPUTqu4bEwGpnFMAAAjCUJGAAA=",
"Subject": "Test Flag",
"SingleValueExtendedProperties@odata.context": "https://outlook.office365.com/api/beta/$metadata#Me/Messages('AAMkAGQ4Yzc2NDkwLTYxYmItNDZmYS1iZjI1LTYyNmY4NTZkMjI1NgBGAAAAAADwPSus7EwaR6q1wNtgoqEMBwDpfBfj8UPUTqu4bEwGpnFMAAAAAAEgAADpfBfj8UPUTqu4bEwGpnFMAAAjCUJGAAA%3D')/SingleValueExtendedProperties",
"SingleValueExtendedProperties": [
{
"PropertyRef": "0x1090",
"Type": "Integer",
"Value": "2"
}
]
}

设置标志就像向 SingleValueExtendedProperties 集合中具有该属性的消息发送 PATCH 一样简单:

新格式:

PATCH https://outlook.office365.com/api/beta/me/messages/{id}

{
"SingleValueExtendedProperties": [
{
"PropertyId": "Integer 0x1090",
"Value": "2"
}
]
}

旧格式:

PATCH https://outlook.office365.com/api/beta/me/messages/{id}

{
"SingleValueExtendedProperties": [
{
"PropertyRef": "0x1090",
"Type": "Integer",
"Value": "2"
}
]
}

最后,根据 MS-OXOFLAG ,值为 2 表示标记为后续,1 表示标记完成。

关于rest - 通过 Office 365 REST API 标记消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31565988/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com