Skip to content

Instantly share code, notes, and snippets.

@bradwright
Last active August 29, 2015 13:56
Show Gist options
  • Save bradwright/9102502 to your computer and use it in GitHub Desktop.
Save bradwright/9102502 to your computer and use it in GitHub Desktop.
Send current MailPlane email to OmniFocus (with Mailplane and Gmail links as notes)
on run {input, parameters}
tell application "Mailplane 3"
set theEmailUrl to currentURL
set theGmailUrl to my replace_chars(theEmailUrl, "mailplane://bradley.wright%40digital.cabinet-office.gov.uk/", "https://mail.google.com/mail/ca/u/0/")
set theSubject to currentTitle
tell application "OmniFocus"
set theTask to theSubject
set theNote to theEmailUrl & "
" & theGmailUrl
tell quick entry
set NewTask to make new inbox task with properties {name:theTask, note:theNote}
select {NewTask}
open
end tell
tell application "System Events"
keystroke tab
end tell
end tell
end tell
return input
end run
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
-- Take the currently open email in MailPlane 3, send it to OmniFocus 2, and archive it
tell application "Mailplane 3"
set theEmailUrl to currentURL
set theSubject to currentTitle
tell application "OmniFocus"
set theTask to theSubject
set theNote to theEmailUrl
tell quick entry
make new inbox task with properties {name:theTask, note:theNote}
open
end tell
tell application "System Events"
keystroke tab
end tell
end tell
end tell
-- Archive the email I just sent
activate application "Mailplane 3"
tell application "System Events"
keystroke "E"
end tell
-- this is the OmniFocus 2 Beta compatible version of the above
on run {input, parameters}
tell application "Mailplane 3"
set theEmailUrl to currentURL
set theSubject to currentTitle
tell application "OmniFocus"
set theTask to theSubject
set theNote to theEmailUrl
tell quick entry
make new inbox task with properties {name:theTask, note:theNote}
open
end tell
tell application "System Events"
keystroke tab
end tell
end tell
end tell
return input
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment