Copy Mail attachment

At my office, our voicemail messages show up in our email inbox as attachments. I currently have a Keyboard Maestro macro set up that lets me select a Mail message and hit a keystroke combination to create an OmniFocus task (via the OmniFocus quick entry window) with the following info pre-filled – context, project, plus the date and time of voicemail message is in the task name. The cursor waits for me at the end of the task name to add in any other info I want to input into the task title, such as the caller name.

I’ve never had good luck with links back to Mail messages, so I’m trying to find a way to copy the voicemail attachment (a WAV file) into the notes field of my OmniFocus task. Any ideas? I have found a way to save attachments as files to a folder on my Mac, and put a link to the file in the OmniFocus task, but ideally I’d like the link to work upon syncing to the iOS OmniFocus app.

Any help is greatly appreciated.

Evan

would love to see how you built your OF macro! I’ve been tinkering trying to do something like that, but yours sounds much more detailed than anything I’ve been able to do so far. Might you be willing to share it?

Fran

Sorry for the delay in responding. I’ve been on the road. When I have some time to sit down, I’ll post the macro here.

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)

1 Like