通过 Office 365 REST API 标记邮件?

Flagged messages via Office 365 REST API?

我正在寻找一种使用 Office 365 REST 消息 API 检测和设置电子邮件 'flagged' 状态的方法。我没有看到 'Flag' 被列为 REST Message, though I do see it listed under 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 'Flag' 属性 有什么建议吗?

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

现在您可以 get/set 更轻松地标记状态。 Message entity 现在有一个 Flag 属性 类型 FollowupFlag。 (如果您在 link 处没有看到它,请确保在页面顶部选择了 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 表示标记完成。