Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

macbook:~ me$ /Applications/ -s the_subject -to < ~/Downloads/
share|improve this question
up vote 3 down vote accepted

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

echo "tell application \"Mail\"

    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 '' 'Some Subject' /path/to/

share|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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .