How to automate Apple Mail message body and URL to omnifocus

Hey all

I’m new to automators but this macsparky applescript to create a hyperlink to an Apple Mail message got me thinking: AppleScript to Link to Apple Mail Message — MacSparky

What I’d like to do is grab some text from an email, generate a hyperlink to that message, then create an Omnifocus item. The basic premise is to write responses to emails outside of the email client rather than being tied to the client. I think the steps would be something like this:

  1. manually select part (or all) of email message body in Apple Mail
  2. run KM script which does the following:
    1. copy selected text in message body in Apple Mail
    2. grab email subject line and sender name from message using Apple Script
    3. open Omnifocus new item
    4. add “respond to sender name re subject line” in Omnifocus item
    5. add hyperlink to email message (Apple Script) as Omnifocus note, + 2 carriage returns
    6. paste email message text from Apple Mail into same Omnifocus item note (below the URL)
    7. somehow get Omnifocus to query me for which project to add Omnifocus item to?
    8. save the Omnifocus item
    9. archive the email message

I haven’t started building the automation yet, but I’m curious if any of you have any thoughts or tips here (or indeed steps I have missed or that won’t work)?

Thanks all, and very best.
Simon

I’d recommend looking at the scripting options for Omnifocus. It sounds like you are planning to have Keyboard Maestro do it via the user interface, but I suspect scripting it would be more efficient and more easily cover off your project request.

Thanks so much.
Perhaps I’ve bitten off more than I can chew here … I have never scripted anything!
But I will certainly look into OF scripting.
Cheers
Simon