is there an easy way to automatically have a sent email (with Apple mail on my mac) be transferred to omnifocus as a “waiting for” task ? I could add my omnifocus address in BCC but I assume that would just push the mail to my inbox?
Personally, I just flag the email in Mail with a flag I have labeled “waiting” (which is green, FWIW ;-). Then I have “check waiting emails” as part of my weekly review. I don’t generally need to follow up on emails more than weekly so this works for me.
Another idea would be to play with this script from the old Omni fora. It was definitely a group effort and seems to have been last touched by @whpalmer4. You activate this AppleScript after a message gets sent. It allows you to select from a mailbox in Mail.app the most recent message, pops up Quick Entry with a task field of that email subject line (prepended with your desired Waiting For text), and populates the note field with a hyperlink to that message.
-- Script originated here: http://dltj.org/article/copy-last-sent-message-as-rtf-link/
-- Edited by whpalmer4 here: http://forums.omnigroup.com/showthread.php?t=20397
-- Various bits of the email pulled out for use in creating new action
global _sub
global _msglnk
global _anchorText
property pNoMessageAvailable : "No message available"
property pUseQuickEntry : true (* if true, Quick Entry window used and left open
if false, actions added directly to Inbox *)
property pChooseAccounts : true (* if true, choose by account, otherwise by message *)
property pActionPrefix : "Waiting for email response re: " (* string added to subject to create action name *)
on run
tell application "OmniFocus"
if (my GetLastSentMailMessage()) then
my GenerateAction()
end if
end tell
end run
on GenerateAction()
-- tell OmniFocus to make a new action in Quick Entry window or Inbox
-- populate new action with note containing descriptive text followed by URL on next line
set TheNote to _anchorText & "
" & _msglnk
set TheAction to pActionPrefix & _sub
tell application "OmniFocus"
if (pUseQuickEntry) then
tell quick entry
open
set NewTask to make new inbox task with properties {name:TheAction, note:TheNote}
end tell
activate
else
tell front document
set NewTask to make new inbox task with properties {name:TheAction, note:TheNote}
end tell
end if
end tell
end GenerateAction
-- GetLastSentMailMessage
-- based on "Copy last sent message as RTF link" by Disruptive Library Technology Jester
-- http://dltj.org/article/copy-last-sent-message-as-rtf-link/
on GetLastSentMailMessage()
tell application "Mail"
-- Ask the user which account to use
set _accts to get accounts
set _Choices to {}
set _Accounts to {}
repeat with eachAccount in _accts
-- Only offer the enabled accounts for the user to choose
if enabled of eachAccount then
set the end of _Accounts to name of eachAccount as string
if (pChooseAccounts) then
set the end of _Choices to name of eachAccount as string
else
try
set _msg to first message of mailbox "Sent" of account (name of eachAccount as string)
set _sub to _msg's subject
on error
set _sub to pNoMessageAvailable
end try
-- set the end of _Choices to subject of first message of mailbox "Sent" of account eachAccount
set the end of _Choices to _sub
end if
end if
end repeat
if (pChooseAccounts) then
set titleStr to "Select Account"
set promptStr to "Select the account from which to copy a link of the last sent message..."
else
set titleStr to "Select Message"
set promptStr to "Select the last sent message to copy as a link..."
end if
set _selection to (choose from list _Choices with title titleStr with prompt promptStr default items (item 1 of _Choices))
if (_selection is false) then return false -- user pressed Cancel button
if (pChooseAccounts) then
set _selectedAccount to _selection
else
-- need to figure out which account corresponded to message chosen
if first item of _selection is pNoMessageAvailable then
return false
end if
set _selectedAccount to false
repeat with _i from 1 to count of _Choices
if first item of _selection is item _i of _Choices then
set _selectedAccount to item _i of _Accounts
exit repeat
end if
end repeat
end if
if _selectedAccount is false then
return false -- shouldn't be possible, but...
end if
set _selectedAccountName to _selectedAccount as string
try
-- Get the "last" message of the Sent mailbox of the selected account
set _msg to first message of mailbox "Sent" of account _selectedAccountName
on error
return false -- probably didn't have any messages
end try
-- Get various properties of the message
set _date to _msg's date sent
try
set _recipient to name of first recipient of _msg
set _test to _recipient
on error
-- if the Recipient's name property was blank, use the e-mail address instead
set _recipient to address of first recipient of _msg
end try
set _sub to _msg's subject
if _sub starts with "Re:" then
-- Remove the "Re:" prefix from messages
set _sub to rich text 5 through (length of _sub) of _sub
else if _sub starts with "re:" then
-- Remove the "re:" prefix from messages
set _sub to rich text 5 through (length of _sub) of _sub
end if
set _msgid to _msg's message id
-- Create the URL to the message
set _msglnk to "message://%3C" & my urlencode(_msgid) & "%3E"
set _anchorText to "Message sent " & _date & " to " & _recipient & " regarding '" & _sub & "'"
end tell
return true
end GetLastSentMailMessage
on urlencode(theText)
do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of theText
end urlencode
This is something I threw together, literally, last week to solve the same issue; got the “get message” part from an Applescript solution to the broken Clip-o-Tron in Yosemite. It’s set up as a launchd job to run every 15 minutes. Looks for @wf in the body of the email; adds recipient name to the beginning of the task name and start date as the date sent.
Yes, I know the date writing to the preference file is ugly.
--GET LAST UPDATE
try
set lastUpdate to do shell script "defaults read com.launchd.waiting update"
set lastDate to do shell script "echo " & lastUpdate & " | awk -F '+' '{print $1}'"
set lastTime to do shell script "echo " & lastUpdate & " | awk -F '+' '{print $2}'"
set lastUpdate to (date (lastDate)) + lastTime
on error
try
set lastWeek to (current date) - 7 * days
set update to (short date string of lastWeek & "+" & time of lastWeek) as string
do shell script "defaults write com.launchd.waiting update " & update
on error
do shell script "logger -t WaitingFor > OmniFocus failed, check preference file"
end try
end try
set now to current date
set update to (short date string of now & "+" & time of now) as string
--PROCESS SENT ITEMS
tell application "Mail"
set theMessages to (messages of sent mailbox) whose date sent is greater than lastUpdate and content contains "@wf"
repeat with theMessage in theMessages
set theMessageID to the message id of the theMessage
set theMessageSubject to the subject of the theMessage
set theMessageBody to the content of the theMessage
set theMessageSender to the sender of the theMessage
set theMessageRecipientName to name of first recipient of the theMessage
set theMessageRecipientAddress to address of first recipient of the theMessage
set theMessageDate to the date sent of the theMessage
set theMessageURL to "message://%3c" & theMessageID & "%3e" & "\r\r" & "From: " & theMessageSender & "\r" & "Subject: " & theMessageSubject & "\r" & "Date: " & theMessageDate & "\r" & "To: " & theMessageRecipientName & " <" & theMessageRecipientAddress & ">" & "\r\r" & theMessageBody
set theAction to theMessageRecipientName & " — " & theMessageSubject
set theContext to "Waiting"
set theNote to do shell script "echo " & quoted form of theMessageURL & " | sed 's/--/—/g'"
tell application "OmniFocus"
tell default document
parse tasks with transport text (theAction & " @" & theContext & " #" & short date string of theMessageDate & "# //" & theNote)
end tell
end tell
end repeat
end tell
do shell script "defaults write com.launchd.waiting update " & update