Last active
March 25, 2018 08:15
-
-
Save frank4565/6937579 to your computer and use it in GitHub Desktop.
Send Multiple Tasks to OmniFocus at Once with Drafts and Pythonista or one task with Launch Center Pro.
Supported Chinese. (Other Unicode characters should also work.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# More information: Send Multiple Tasks to OmniFocus at Once with Drafts and Pythonista or one task with Launch Center Pro. Supported Chinese. (Other Unicode characters should also work.) | |
# Script name: MultiLineOmniFocus | |
# Drafts "URL Action": pythonista://MultiLineOmniFocus?action=run&argv=[[draft]]%0Adrafts | |
# Launch Center Pro: pythonista://MultiLineOmniFocus?action=run&args={{[prompt:New Item]}}%0Alaunchpro | |
# or Install from http://launchcenterpro.com/tdp7fb | |
# Modified from email script by OMZ: ImageMail | |
# Modified from script by @Thinkbond from Zhihu.com (http://www.zhihu.com/question/20888606/answer/17093178) | |
# Inspired by http://n8henrie.com/2013/03/send-multiple-tasks-to-omnifocus-at-once-with-drafts-and-pythonista | |
import smtplib | |
from email.header import Header | |
from email.mime.multipart import MIMEMultipart | |
from email import encoders | |
import sys | |
import webbrowser | |
import console | |
import urllib | |
def main(): | |
tasks = sys.argv[1].splitlines() | |
callback = tasks[-1] | |
tasks = tasks[0:-1] | |
### CHANGE THESE VALUES: | |
to = '@sync.omnigroup.com' | |
gmail_user ='@gmail.com' | |
gmail_pwd = '******' | |
console.clear() | |
print 'Starting SMTP Server' | |
smtpserver = smtplib.SMTP("smtp.gmail.com", 587) | |
smtpserver.ehlo() | |
smtpserver.starttls() | |
smtpserver.ehlo | |
smtpserver.login(gmail_user, gmail_pwd) | |
for task in tasks: | |
outer = MIMEMultipart() | |
outer['Subject'] = urllib.unquote(task).decode('utf8') | |
outer['To'] = to | |
outer['From'] = gmail_user | |
outer.preamble = 'You will not see this in a MIME-aware email reader.\n' | |
composed = outer.as_string() | |
print 'Sending Task ' + str(tasks.index(task) + 1) | |
smtpserver.sendmail(gmail_user, to, composed) | |
smtpserver.close() | |
print 'Done' | |
console.clear() | |
webbrowser.open(callback + '://') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment