Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'open -a Mail' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
open -a Mail
Authored by: vectors_to_final on Nov 23, '03 06:17:57PM
Not with "open". You're better off using AppleScript for this sort of thing. You can use the "osascript" command to run arbitrary scripts from the command line. Apple has a good script for this in a Q&A document, but if you want something quick, you might try something like this:

tell application "Mail"
	set newMessage to (a reference to (make new outgoing message))
	
	tell newMessage
		make new recipient at beginning of to recipients ¬
			with properties {address:"someone@somewhere.com"}
		
		set the subject to "Testing"
		set the content to "Hello World!"
		
		tell content
			make new attachment ¬
				with properties {file name:"/path/to/file"} ¬
				at after the last word of the last paragraph
		end tell
		
		set visible to true
	end tell
end tell

This will create a new message, but it won't send it. If you want to send the message automatically, change "set visible to true" to "send".

[ Reply to This | # ]