A Service for Merlin Mann

A Service for Merlin Mann

If you’ve not heard of Merlin Mann, well, he’s the entertaining co-host of such podcasts as Back to Work and You Look Nice Today (NSFW), and has appeared on numerous tech podcasts like MacBreak Weekly, which is where I first heard him. He also has number of websites bearing his imprint.

Recently Merlin appeared on Brett Terpstra’s Systematic podcast and during his various ramblings on productivity he mentioned:

There are so few ways for me to send email without reading email…I just don’t want to see email until I’m ready to see it…I have this in iOS, [but] I have no idea how to do that on my Mac…I just want to to type stuff in TextMate and hit a button and have it go.

Here’s that “detailed AppleScript” you asked for, Merlin, wrapped up in a Service:

on run {input, parameters}
    set unattended to true -- set to false to see what Mail is doing

    set theClip to input as text
    if (count of paragraphs of theClip) > 1 then
        set tid to AppleScript's text item delimiters
        set AppleScript's text item delimiters to {return, linefeed, return & linefeed, character id 8233, character id 8232}

        set theSubject to paragraph 1 of theClip
        set theRecipient to paragraph 2 of theClip
        set atSign to offset of "@" in theRecipient
        if atSign > 0 and (count of paragraphs of theClip) > 2 then
            set theMessage to paragraphs 3 thru -1 of theClip
        else
            set theRecipient to ""
            set theMessage to paragraphs 2 thru -1 of theClip
        end if

        -- Without this the paragraphs all run together
        set theMessage to theMessage's text items
        set theMessage to theMessage as text
        set AppleScript's text item delimiters to tid

        tell application "Mail"
            if not unattended then activate
            set outgoing_message to make new outgoing message
            tell outgoing_message
                set the subject to theSubject
                set the content to theMessage as string
                -- This should work for multiple recipients 
                -- as long as they're separated by commas
                make new to recipient at end of to recipients with properties {address:theRecipient}
                if not unattended then set visible to true
                if unattended then send outgoing_message
            end tell
        end tell
    end if

    return input
end run

To use this Automator workflow, download it below, unzip it, and place it in your Services directory1 at

~/Library/Services

Then in any app, select some text and activate the New Mail Message from Selection Service, which you can find in the Services menu under the application menu. You can also set a key binding for the service at System Preferences > Keyboard > Keyoboard Shortcuts > Services.

The Service expects two or more lines of text. The first line will be used for the message subject. If you know the address(es) for your recipient(s), separate them with commas on line two; otherwise, line two and following will be the body of the message.

Merlin didn’t want to even see Mail, so this workflow sends the message without intervention, but if you want to interact with Mail open the workflow in Automator and update the second line appropriately. The workflow will automatically show the message in Mail if you don’t supply any recipients.

I love you, (Mister) Mann!


  1. The tilde (“~”) indicates your home, or “user,” directory. Your user Library is hidden in OS X 10.7 and above; to access it in Finder, click the Go menu while holding down the option key.