REST Resource: users.settings.filters

资源:过滤器

Gmail 过滤器的资源定义。过滤器会应用于特定邮件,而不是整个电子邮件会话。

JSON 表示法
{
  "id": string,
  "criteria": {
    object (Criteria)
  },
  "action": {
    object (Action)
  }
}
字段
id

string

服务器分配给过滤器的 ID。

criteria

object (Criteria)

过滤条件的匹配条件。

action

object (Action)

过滤器执行的操作。

条件

消息匹配条件。

JSON 表示法
{
  "from": string,
  "to": string,
  "subject": string,
  "query": string,
  "negatedQuery": string,
  "hasAttachment": boolean,
  "excludeChats": boolean,
  "size": integer,
  "sizeComparison": enum (SizeComparison)
}
字段
from

string

发件人的显示名称或电子邮件地址。

to

string

收件人的显示名称或电子邮件地址。包括“收件人”“抄送”和“密送”标头字段中的收件人。您只需使用电子邮件地址的本地部分即可。例如,“example”和“example@”都与“example@gmail.com”匹配。此字段不区分大小写。

subject

string

邮件主题中不区分大小写的字词。系统会去除尾随空格和前导空格,并合并相邻空格。

query

string

仅返回与指定查询匹配的消息。支持与 Gmail 搜索框相同的查询格式。例如 "from:someuser@example.com rfc822msgid:<somemsgid@example.com> is:unread"

negatedQuery

string

仅返回与指定查询不匹配的消息。支持与 Gmail 搜索框相同的查询格式。例如 "from:someuser@example.com rfc822msgid:<somemsgid@example.com> is:unread"

hasAttachment

boolean

邮件是否包含任何附件。

excludeChats

boolean

响应是否应排除聊天内容。

size

integer

整个 RFC822 邮件的大小(以字节为单位),包括所有标头和附件。

sizeComparison

enum (SizeComparison)

消息大小(以字节为单位)与大小字段之间的关系。

SizeComparison

确定应如何将大小字段与消息大小进行比较。

枚举
unspecified
smaller 查找小于指定大小的邮件。
larger 查找大于给定大小的邮件。

操作

对消息执行的一组操作。

JSON 表示法
{
  "addLabelIds": [
    string
  ],
  "removeLabelIds": [
    string
  ],
  "forward": string
}
字段
addLabelIds[]

string

要添加到邮件中的标签列表。

removeLabelIds[]

string

要从邮件中移除的标签的列表。

forward

string

应将邮件转发到的电子邮件地址。

方法

create

创建过滤条件。

delete

立即永久删除指定的过滤条件。

get

获取过滤器。

list

列出 Gmail 用户的邮件过滤器。