Last active
December 22, 2015 01:19
-
-
Save trevershick/6395372 to your computer and use it in GitHub Desktop.
Applescript to take flagged e-mail in Apple Mail and create Yojimbo items tagged with 'todo'. I sourced quite a bit of this from multiple places. I apologize for not keeping the references...
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
| #! /usr/bin/osascript | |
| set _count to 0 | |
| if not (application "Mail" is running and application "Yojimbo" is running) then | |
| return | |
| end if | |
| tell application "Mail" | |
| repeat with _account in accounts | |
| try | |
| set _inbox to _account's mailbox "Inbox" | |
| set _messages to (a reference to (every message of _inbox whose flagged status is true)) | |
| set _msglist to contents of _messages | |
| repeat with _message in _msglist | |
| --try | |
| set theSubject to "Handle @email \"" & subject of _message & "\" from " & sender of _message | |
| set theBody to content of _message | |
| tell application "Yojimbo" | |
| set newnote to (make new note item with properties {contents:theBody, name:theSubject}) | |
| add tags {"todo"} to newnote | |
| end tell | |
| -- don't forget to unflag the message :) | |
| set flagged status of _message to false | |
| delete _message | |
| --end try | |
| set _count to _count + 1 | |
| end repeat | |
| end try | |
| end repeat | |
| end tell | |
| tell application "System Events" | |
| set isRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0 | |
| end tell | |
| if isRunning and _count > 0 then | |
| tell application id "com.Growl.GrowlHelperApp" | |
| set the allNotificationsList to {"Basic Notification"} | |
| set the enabledNotificationsList to allNotificationsList | |
| register as application "Make Yojimbo TODO" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Script Editor" | |
| notify with name "Basic Notification" title "Yojimbo TODOs Created" description "Created " & _count & " Yojimbo TODOs" application name "Make Yojimbo TODO" | |
| end tell | |
| end if | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment