Created
September 5, 2014 05:24
-
-
Save bachya/48fd6a35a7686b87bee1 to your computer and use it in GitHub Desktop.
Apple Mail implementation of https://gist.github.com/bachya/7eb70e95f2ff12fce918
This file contains 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
(* | |
### SCRIPT NAME | |
Add Emails to OmniFocus | |
### DESCRIPTION | |
A simple script aimed at working with "todo" emails. The script | |
accomplishes two things: | |
1. An Omnifocus task is created related to the email | |
2. The email is filed into a specific folder and marked as unread | |
### INSTALLATION | |
1. Download the .workflow file somewhere on your filesystem. | |
2. Double click on it. | |
3. You should be good to go. :) | |
### LICENSE | |
(The MIT License) | |
Copyright © 2014 Aaron Bach [email protected] | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
author: Aaron Bach | |
date: July 27, 2014 | |
version: 1.0.0 | |
*) | |
on run {input, parameters} | |
-- The Mail Drop address to use | |
set mailDropAddress to "YOUR MAIL DROP ADDRESS" | |
-- DO NOT CHANGE BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING. | |
-- Determine whether OmniFocus is running. | |
tell application "System Events" | |
set omnifocusActive to count (every process whose name is "OmniFocus") | |
end tell | |
tell application "Mail" | |
set theSelection to selection | |
repeat with aMessage in theSelection | |
set theSender to extract name from (sender of aMessage) | |
set theTitle to the subject of aMessage | |
set theNotes to the content of aMessage | |
set theSubject to "Respond to email from " & theSender & ": " & theTitle | |
set theCombinedBody to "message://%3c" & message id of aMessage & "%3e" | |
if omnifocusActive > 0 then | |
-- OmniFocus is running, so insert a task into it directly. | |
tell application "OmniFocus" to tell document 1 | |
make new inbox task with properties {name:theSubject, note:theCombinedBody} | |
end tell | |
else | |
-- OmniFocus isn't running, so use the Mail Drop method. | |
do shell script "echo \"" & quoted form of theCombinedBody & "\" | mail -s \"" & theSubject & "\" " & mailDropAddress | |
end if | |
-- Apply the "@FollowUp" MailTags keyword to the message. | |
using terms from application "MailTagsHelper" | |
set keywords of aMessage to "@FollowUp" | |
end using terms from | |
end repeat | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment