Open Outlook new message window from terminal

ms officeterminal

I would like to open a new message Outlook window from terminal and ideally prefill the message body too.

Any ideas on how to accomplish this? Txn!

Best Answer

Office is moderately scriptable with AppleScript, so the command line interface to AppleScript can get the job done.

Try this (adapted from this blog post by Jim Shank), replacing the subject text, name and email as appropriate:

osascript -e 'tell application "Microsoft Outlook"' -e 'set newMessage to make new outgoing message with properties {subject:"My Subject"}' -e 'make new recipient at newMessage with properties {email address:{name:"John Smith", address:"jsmith@example.com"}}' -e 'open newMessage' -e 'end tell'

It's a bit lengthy, but it will get the job done. You could adapt this into a small script that you could call and provide parameters to more concisely (i.e. sendoutlook john@example.com "My Subject" "Hi John, blah blah blah") without too much work, but that's probably best left as a separate question.