up vote 1 down vote favorite
share [g+] share [fb]

I would like to start writing an email with Mail.app from Terminal, and add an attachment. Something like this:

macbook:~ me$ /Applications/Mail.app/Contents/MacOS/Mail -s the_subject -to email@domain.com < ~/Downloads/file.zip
link|improve this question
feedback

1 Answer

up vote 2 down vote accepted

You can do this using AppleScript. Here's a quick (quickly tested) bash script which is close to what you want.

#!/bin/bash
echo "tell application \"Mail\"
    activate

    set MyEmail to make new outgoing message with properties {visible:true, subject:\"$2\", content:\"Some Message Here\"}
    tell MyEmail
        make new to recipient at end of to recipients with properties {address:\"$1\"}
        make new attachment with properties {file name:((\"$3\" as POSIX file) as alias)}
    end tell
end tell
" | osascript

Usage: compose_email 'email@domain.com' 'Some Subject' /path/to/attachment.zip

link|improve this answer
Script needs a few tweaks... stay tuned! – Josh Mar 31 '10 at 2:34
Script tested and working – Josh Mar 31 '10 at 2:49
Thanks, thats exactly what i was looking for. – DerKlops Mar 31 '10 at 7:02
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.