OK, let's see if I can post this properly. This is a long macro, so I've broken it into 3 screenshots. I'm also posting the macro to import, and the text of the AppleScript in the macro (which I think I found in these forums, along with many of the other pieces of the macro). The key thing in running this is to make sure the Mail message is selected at the time you fire the macro with the keystroke. Otherwise, if the cursor focus is elsewhere, it won't work.
Caveat: I'm far from skilled at this stuff, so much of this might be cringe-inducing to those who know what they're doing. I'm still trying to figure out a way to auto-play the message and move the cursor to the Omnifocus task input box. Also, the voicemail messages in my work's system don't play nice with Omnifocus - the links they generate are broken. That's not a function of the macro or of OmniFocus, but of how my work server generates the email messages. I'm currently struggling through trying to modify this macro to copy the voicemail attachment into Dropbox, and generate a Dropbox link that will work across platforms.
For the below macro to work, you probably will either need to create an OmniFocus project and context that match the ones I use in the macro, or modify the macro to match your own project/context. In this macro, the typing actions ("voice" and "phone") find my "voicemail" project and "phone" context.
The AppleScript, and the Insert Text right after it, name the task starting with "**VM" followed by the date and time the voicemail message was sent. I can then sort my voicemail messages by date and time.
The Applescript from above is as follows:
-- Gets the date of the selected message
-- https://discussions.apple.com/thread/6751836?start=0&tstart=0
-- This returns the date as "Day_of_the_Week, Full_Month Day, Year at Time AM/PM"
-- Date Conversion added by RSH - 2016-02-02
set dateList to {}
tell application "Mail" to if running then
repeat with tMsg in (get selection)
set end of dateList to the (date received of tMsg) as rich text
end repeat
set monthList to {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
set numberList to {"1", "2", "3", "4", "5", "6", "7", "8", "9"}
-- Separating Email Date for Reordering
set dateString to item 1 of dateList
set emailYear to word 4 of dateString
set emailMonth to word 2 of dateString
set emailDay to word 3 of dateString as string
set emailTimeHours to word 6 of dateString
set emailTimeMinutes to word 7 of dateString
set emailTimeSeconds to word 8 of dateString
set emailAMPM to word 9 of dateString
-- Getting month value, added "as string" to fix single numbers to double digit (1->01)
repeat with i from 1 to the count of monthList
if item i of monthList is emailMonth then set monthPosition to i as string
end repeat
-- Concatenating "0" onto single digit numbers to make them double
if numberList contains monthPosition then set monthPosition to "0" & monthPosition
if numberList contains emailDay then set emailDay to "0" & emailDay
-- Creating Reordered Date with Month Name
-- set orderedDateString to emailYear & "-" & emailMonth & "-" & emailDay & " " & emailTimeHours & ":" & emailTimeMinutes " " & emailAMPM
-- Creating Reordered Date with Month Value
set orderedDateString to emailYear & "-" & monthPosition & "-" & emailDay & " " & emailTimeHours & ":" & emailTimeMinutes & " " & emailAMPM
return orderedDateString
end if
Here's the complete macro:
Voicemal Message.kmmacros (7.0 KB)