【问题标题】:Gmail Timed Filters to Delete msgs between 8am - 5pmGmail 定时过滤器可在上午 8 点至下午 5 点之间删除邮件
【发布时间】:2014-09-27 02:30:37
【问题描述】:

如何在 gmail 中设置某些内容以删除在上午 8 点至下午 5 点之间匹配 gmail 过滤器的消息

我在想有可能通过 google 应用程序脚本来实现,并想知道是否有人已经制作过这样的东西?

【问题讨论】:

    标签: email gmail-api


    【解决方案1】:

    我会遍历最上面的线程(不幸的是最多 20 个)并检查它们的日期时间戳,然后您可以使用相对简单的 delete api 删除它们。

        CLIENT_SECRET_FILE = 'client_secret.apps.googleusercontent.com.json'
        OAUTH_SCOPE = 'https://www.googleapis.com/auth/gmail.compose'
        STORAGE = Storage('gmail.storage')
        flow = flow_from_clientsecrets(CLIENT_SECRET_FILE, scope=OAUTH_SCOPE)
        http = httplib2.Http()
        credentials = STORAGE.get()
        if credentials is None or credentials.invalid:
            credentials = run(flow, STORAGE, http=http)
        http = credentials.authorize(http)
        gmail_service = build('gmail', 'v1', http=http)
        threads = gmail_service.users().threads().list(userId='me', maxResults=1).execute()
        if threads['threads']:
            for thread in threads['threads']:
    

    我在这里为您编写的代码为您完成了简单的部分,您需要做的就是检查该特定消息的date-time,然后决定是否要delete

    【讨论】:

      猜你喜欢
      • 2022-01-16
      • 1970-01-01
      • 1970-01-01
      • 2014-09-08
      • 1970-01-01
      • 2018-12-30
      • 1970-01-01
      • 1970-01-01
      • 2015-06-20
      相关资源
      最近更新 更多