This one moves all of my new drafts into my inbox every 15 minutes.

I don’t think there is a way to do this without having to check all of the time.

import libgmail
import time
from getpass import getpass

name = raw_input("Gmail account name: ")
pw = getpass()

ga = libgmail.GmailAccount(name, pw)
ga.login()
while 1:
    for thread in ga.getMessagesByFolder("drafts", True):
        if len(thread) == 1: #only apply to new threads
            print thread.id, thread.subject
            thread._account._doThreadAction("ib", thread)
    time.sleep(15 * 60)
Advertisements