First, copy the script (below) to your local machine into your user folder ~/Library/Application Support/Microsoft/Office/Outlook Script Menu Items.
You can navigate to that path in a new Finder window by holding the Option key and opening the Go menu. You should see the Library option appear there. Now, just follow the path to the location mentioned above.
After you create the file there, create the file todoist-token.txt. In this file, you'll want to copy the API token from your account in Todoist. Open your browser, navigate and login to Todoist. Once you see your task lists, click the wheel and navigate to Settings. Once there, select Account. In the bottom half to the window, you'll see API token. Copy that token and place it in the file, todoist-token.txt. Make sure there are no new lines below the token. This will cause an error when parsing that file.
Once you have completed these two steps, it should be possible to open Outlook, select a message and send it to Todoist. Click the AppleScript icon in the menu bar and locate Todoist Task. Clicking this will automatically send it to Todoist and move the message in the folder "Archive".
Features of this script:
You can navigate to that path in a new Finder window by holding the Option key and opening the Go menu. You should see the Library option appear there. Now, just follow the path to the location mentioned above.
After you create the file there, create the file todoist-token.txt. In this file, you'll want to copy the API token from your account in Todoist. Open your browser, navigate and login to Todoist. Once you see your task lists, click the wheel and navigate to Settings. Once there, select Account. In the bottom half to the window, you'll see API token. Copy that token and place it in the file, todoist-token.txt. Make sure there are no new lines below the token. This will cause an error when parsing that file.
Once you have completed these two steps, it should be possible to open Outlook, select a message and send it to Todoist. Click the AppleScript icon in the menu bar and locate Todoist Task. Clicking this will automatically send it to Todoist and move the message in the folder "Archive".
Features of this script:
- Create a new task in Todoist.
- Create a new note on the Todoist with the body converted to plain text.
- NOTE: Todoist does not support HTML notes at this time.
- Archive the message to your "Archive" folder.
Also, view this script on github. For further enhancements and fixes - https://github.com/mhorner/OutlookToTodoist
(*Create Todoist task from email*)on replace_chars(this_text, search_string, replacement_string)set AppleScript's text item delimiters to the search_stringset the item_list to every text item of this_textset AppleScript's text item delimiters to the replacement_stringset this_text to the item_list as stringset AppleScript's text item delimiters to ""return this_textend replace_chars-- get todoist token from text fileset todoistToken to my replace_chars(read file ((path to home folder as text) & "Library:Application Support:Microsoft:Office:Outlook Script Menu Items:todoist-token.txt"), "", "")tell application "Microsoft Outlook"-- get the currently selected message or messagesset selectedMessages to current messages-- if there are no messages selected, warn the user and then quitif selectedMessages is {} thendisplay dialog "Please select a message first and then run this script." with icon 1returnend ifrepeat with theMessage in selectedMessages-- get the information from the message, and store it in variablesset theName to subject of theMessageset theSender to sender of theMessageset thePriority to priority of theMessageset theBody to content of theMessageif thePriority is priority high thenset thePriority to "4"elseset thePriority to "0"end if-- remove new lines from the body firstset theBody to do shell script "echo '" & theBody & "'| tr -d '\\r'"-- remove HTML tags from the body creating a plain text outputset plainText to do shell script "echo '" & theBody & "' | /usr/bin/textutil -stdin -convert txt -stdout"-- create a new task with the information from the messageset newItem to do shell script "curl -X POST -d 'content=" & theName & " for " & name of theSender & "' -d 'token=" & todoistToken & "' -d 'priority=" & thePriority & "' -d 'date_string=today' https://todoist.com/API/additem -d 'note=" & plainText & "'"set theAccount to account of theMessageset archiveFolder to folder "Archive" of theAccountmove theMessage to archiveFolderend repeatend tell
Hi Matt,
ReplyDeleteInteresting post! I have been looking for a way to achieve the same thing. If I wasn't interested in moving the mails to the Archive folder, how would the script change? I want them to stay in the inbox folder (or the folder they are currently in).
Thanks in advance!
Best,
Oskar
Just take out the move command towards the end. That should do it. (And possibly the two lines before it, since it looks like those are just setting up variables for the move.)
DeleteHi Matt,
ReplyDeleteThanks for putting this together. I hope ToDoist gets their act together and offers you something to help them implement this.
Unfortunately, this doesn't work for me. I'm running Outlook 2011 on a MId 2011 iMac (10.10.2). Here's the error message I get, referencing the line 10 from the bottom (that starts "set plainText to do shell script...") ([leftbracket substitutes for < symbol, below, due to the tag IFRAME not being allowed in this message)
error "Microsoft Outlook got an error: sh: -c: line 476: syntax error near unexpected token `<'
sh: -c: line 476: `document.write('[leftbracket]iframe src=\"'+(\"https:\"==document.location.protocol?\"https:\":\"http:\")+\"//rs.gwallet.com/r1/pixel/x20726\"+'r'+Math.round(1E7*Math.random())+'\" width=\"1\" height=\"1\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\">[/iframe>');
'" number 2
Any suggestions?
Thanks!
Is there anyway to make this work with Outlook for Mac 2016?
ReplyDeleteCan you do something like this for Outlook 2016 (MAC)?
ReplyDelete