简体   繁体   English

通过Office 365 REST API标记的邮件?

[英]Flagged messages via Office 365 REST API?

I'm looking for a way to detect & set the 'flagged' status of an email using the Office 365 REST Message API. 我正在寻找一种方法来使用Office 365 REST Message API检测和设置电子邮件的“已标记”状态。 I don't see 'Flag' listed as a property of a REST Message , though I do see it listed under Exchange Web Services . 我没有看到'Flag'被列为REST消息的属性,但我确实看到它列在Exchange Web服务下

I've attempted to make a REST call adding Flag to filtered properties, as well as SingleValueExtendedProperties and MultiValueExtendedProperties like: 我试图做一个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

all of these have come back with some form of: 所有这些都以某种形式回归:

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

Any suggestions on how to get access to the Outlook 'Flag' property via the REST API? 有关如何通过REST API访问Outlook“Flag”属性的任何建议?

UPDATE: There is now a Flag property on Message on the /beta endpoint. 更新: /beta端点上的Message上现在有一个Flag属性。 This is the recommended way to do this. 这是推荐的方法。 I'll leave the other information there for historical purposes and to help folks trying to set other extended properties. 我会将其他信息留在那里用于历史目的,并帮助那些尝试设置其他扩展属性的人。

Now you can get/set flag status much easier. 现在,您可以更轻松地获取/设置标志状态。 The Message entity now has a Flag property of type FollowupFlag . Message实体现在具有FollowupFlag类型的Flag属性。 (If you don't see it at that link, be sure that the beta version is selected at the top of the page). (如果您没有在该链接上看到它,请确保在页面顶部选择了beta版)。

You can mark a message as flagged by sending a PATCH with the following payload: 您可以通过发送具有以下有效内容的PATCH将消息标记为已标记:

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

OLD METHOD (Using extended properties) 旧方法(使用扩展属性)

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. 您需要转到新格式。

What you need to do is include an $expand query parameter to expand the SingleValueExtendedProperties collection, with a $filter sub-parameter to indicate the property you want to include. 您需要做的是包含一个$expand查询参数来展开SingleValueExtendedProperties集合,并使用$filter子参数来指示您要包含的属性。 In this case, you want PidTagFlagStatus . 在这种情况下,您需要PidTagFlagStatus Try a query like this: 尝试这样的查询:

New Format: 新格式:

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

Old Format: 旧格式:

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

Messages that aren't flagged at all will just not have that property returned. 根本没有标记的消息将不会返回该属性。 Messages that do will look something like this: 这些消息看起来像这样:

New Format: 新格式:

{
  "@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"
    }
  ]
}

Old Format: 旧格式:

{
  "@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"
    }
  ]
}

Setting the flag is as simple as sending a PATCH to the message with that property in the SingleValueExtendedProperties collection: 设置标志就像将PATCH发送到SingleValueExtendedProperties集合中具有该属性的消息一样简单:

New Format: 新格式:

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

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

Old Format: 旧格式:

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

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

Finally, per MS-OXOFLAG , a value of 2 means flagged for follow up, and 1 means flag completed. 最后,根据MS-OXOFLAG ,值2表示标记为后续,1表示标志已完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM