【问题标题】:using gmail api to filter out emails from some format使用 gmail api 过滤掉某种格式的电子邮件
【发布时间】:2021-11-21 18:31:18
【问题描述】:

我正在尝试使用 gmail api 并且很难使用过滤器。 我想排除一些电子邮件, 例如过滤发送到“myname@mycompany.com”的电子邮件, 在 gmail api 文档中找不到任何东西。

我正在使用 nodejs 客户端并像这样构建查询。

    const result = await gmail.users.messages.list({
      auth: oauth2Client,
      userId: "me",
      q: `in:sent after:2021/09/01`
    })

gmail api 是否有类似 not:myname@mycompany.com 的内容 或类似 exclude:myname@mycompany.com 或者这根本不可能?

【问题讨论】:

    标签: node.js email google-api gmail gmail-api


    【解决方案1】:

    您能否在查询中附加-keyword

    const result = await gmail.users.messages.list({
          auth: oauth2Client,
          userId: "me",
          q: `in:sent after:2021/09/01 -myname@mycompany.com`
        });
    

    【讨论】:

    • 效果很好!感谢您的回答!如果您不介意,请跟进问题 - 我可以将该查询转换为排除来自@mycompany.com 的任何电子邮件吗?只需添加 -@mycompany.com 就可以了吗?
    • 是的,您可以使用 -keyword 规则排除任何关键字,例如 google 搜索
    • 非常感谢!
    猜你喜欢
    • 2021-10-16
    • 1970-01-01
    • 2017-06-28
    • 2020-11-16
    • 1970-01-01
    • 2017-05-15
    • 2018-01-26
    • 2021-10-14
    • 1970-01-01
    相关资源
    最近更新 更多