Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 protected] < ~/Downloads/file.zip
share|improve this question
add comment

1 Answer

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.

#!/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 protected]' 'Some Subject' /path/to/attachment.zip

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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