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


Click here to return to the 'Create Mail messages with attachments from Terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create Mail messages with attachments from Terminal
Authored by: wgscott on Oct 12, '04 01:55:38PM
open -a Mail foo.bar opens a mail send to window with the file foo.bar embedded. Also, here is a
    drop-in replacement
for /usr/bin/mail that I have used.

[ Reply to This | # ]
Create Mail messages with attachments from Terminal
Authored by: hypert on Oct 13, '04 09:17:53PM
This is a great tip! Thanks, "WG" (and thanks for emailing me directly, too). At first, I had problems with the AppleScript created out of that Perl script. Essentially:

tell application "Mail"
	set newMessage to make new outgoing message
	tell newMessage
		set subject to "invisible"
		set content to "hello"
		make new to recipient at end of to recipients with properties {address:"foo@bar.com"}
		set visible to false
	end tell
	send newMessage
end tell
Turns out that I had an old "Classic" app laying around in a half dozen places called "Mail", and AppleScript insisted on trying to send these commands to that app (needless to say, that failed miserably).

So, if anyone else is having problems with WG's Perl script, make sure "Mail" is really Apple's Mail.app.

Now, I'm going to work on getting this talk to Entourage! If it works, I'll post it....

[ Reply to This | # ]
Create Mail messages with attachments from Terminal
Authored by: hypert on Oct 13, '04 11:21:27PM
I figured out (i.e., Googled and hacked my way toward) a simple Applescript for sending mail through Entourage.

tell application "Microsoft Entourage"
	--set newMsg to make new outgoing message with properties {recipient:{recipient type:to recipient, address:"foo@bar.com"}}
	set newMsg to make new outgoing message with properties {to recipients:"foo1@bar.com, foo2@bar.com"}
	set the subject of newMsg to "send mail through Entourage using AppleScript"
	set the content of newMsg to "line 1\nline 2"
	send newMsg
end tell

This could easily be inserted into the original Perl script (I'll hack it in later), but doesn't have all the options of Apple's Mail. I can't find a way to specify CC addresses. In fact, it's kind of complex to specify the TO address (there are two examples above) and apparently has to be done while creating the newMsg object. I've seen online example of being able to set the recipients with a "set" command (like the subject and content), but it simply wouldn't work for me.

I'd welcome any comments to this Entourage AppleScript.

[ Reply to This | # ]