Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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!

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted
+50

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.

share|improve this answer
    
Works perfectly! Thanks! ;-) –  Sander Versluys Dec 10 '12 at 15:53
    
You're welcome, glad it worked for you. –  robmathers Dec 10 '12 at 16:34
add comment

The first step is to change your default mail reader on your Mac:

  1. Open Mail.app
  2. Choose Mail...Preferences from the menubar
  3. On the General tab, change your Default email reader to Outlook.

Next from the terminal, use the open command with the mailto: URL. Here is an example:

open "mailto:someone@example.com?subject=This is my subject&body=This is my body"

You can see more examples of the mailto: URL here: http://www.rapidtables.com/web/html/mailto.htm

share|improve this answer
    
This is an option but my default client needs to be gmail in the browser. Thanks though! –  Sander Versluys Dec 10 '12 at 15:52
    
is there a way to add an attachment using this method? –  Adam Johns Jan 15 at 18:47
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.