Create Message with Apple Mail from commandline I am not working on an Apple computer, but I know people who do. I want to create a shell script for them which allows them to create a larger number of messages automatically. It should look like this:

function mymail {
  Mail ....  
}

mymail "recipient1@mail.com" "subject1" "message text" "attachment.txt"


Can I pass commandline arguments to Apple Mail in the mymail function which will allow me to create these messages from the shell? The mailer should not actually send the messages. It should just display message windows or save them in some folder to be reviewed by the sender.
I haven't really tested this, but you could use AppleScript for it.

mymail() {
    osascript - "$@" &lt;&lt;-END
on run args
tell app "Mail"
set m to make new outgoing message with properties {subject:item 2 of args, content:item 3 of args, visible:true}
tell m
make new to recipient at end of to recipients with properties {address:item 1 of args}
if number of args is 4
make new attachment with properties {file name:POSIX file (item 4 of args)} at after last paragraph
end
end
activate
end
end
END
}