Posted on 04-06-2017 06:03 PM
Hello,
I am trying to find for a script where it would open a new email window on 2016 MS outlook with a pre filled "TO:" field and everything else is blank. I tried different scripts i found online but non of them worked.
thanks
Posted on 04-06-2017 07:14 PM
The following Applescript does the trick.
tell application "Microsoft Outlook"
activate
set sendToAddress to "someone@company.com"
set theMessage to make new outgoing message with properties {subject:""}
make new recipient at theMessage with properties {email address:{name:"FirstName LastName", address:sendToAddress}}
open theMessage
end tell
You would need to replace the someone@company.com with a real email address, and also the "FirstName LastName" with their name or just use the same string as the email address.
By the way, it can only be done with Applescript. Outlook and other MS apps don't work with things like shell scripts.
Posted on 04-06-2017 08:25 PM
Thanks for your help! it works on applescript editor i just changed tell application "Microsoft Outlook" to tell application "/Applications/Microsoft Outlook.app" However, when I applied it on self service and ran the command, it asked me to download command line developer tools otherwise it will not complete the command.
Posted on 04-06-2017 10:01 PM
You don't need to provide a full path to an application in Applescript to get the script to address an application. A simple tell application "Microsoft Office"
is enough to get the app to open. Were you seeing something different when you ran it? Applescript won't understand something like tell application "/Applications/Microsoft Outlook.app"
because that's a POSIX path that hasn't been specified as such in the script, so it won't really know what to do with that.
As for the Xcode dialog prompt, I'm guessing what you'd need to do is wrap this AS into a bash script and execute it that way from a Casper/Self Service policy. It's possible the way it was created in the JSS it's not seeing it as an Applescript or something.
Try doing this
#!/bin/sh
/usr/bin/osascript <<EOF
tell application "Microsoft Outlook"
activate
set sendToAddress to "someone@company.com"
set theMessage to make new outgoing message with properties {subject:""}
make new recipient at theMessage with properties {email address:{name:"FirstName LastName", address:sendToAddress}}
open theMessage
end tell
EOF
Posted on 04-07-2017 04:04 AM
Thanks! the only reason why i provided the full path is because every time i run it, it opens my MS office on parallels. I tried doing your script but for some reason it still won't run but this time xcode isn't showing up anymore. I'm almost there. i just need to do a little more research. Thank you!
Posted on 04-08-2017 04:16 PM
@edelcastillo, Parallels does have a setting to disable shared applications in your VM's configuration settings. This would avoid having to enter the path in your script. It's all or nothing, though, so if you like some of your files to just open in the Windows apps, this won't be your solution.
Posted on 08-23-2019 04:48 AM
@mm2270 Thank you for sharing this short script to compose mail., I am finding difficult in attaching zip file.
I am extracting logs to user Desktop with .Zip file
zip "${logdir}.zip"
/usr/bin/osascript <<EOF
tell application "Microsoft Outlook"
activate
set sendToAddress to "support.mac@xyz.com"
set theMessage to make new outgoing message with properties {subject:"Self Service: $HostName Logs for Analysis"}
make new recipient at theMessage with properties {email address:{name:"MAC Support, xyz company support.mac@xyz.com", address:sendToAddress}}
open theMessage
end tell
EOF