Using Outlook to Start a New Message.

BenRoyalCT
New Contributor

Hello,

I have followed a script that allows a user to display details of their computer and submit a new Support Desk Request by pressing a button.  This appears to work fine on MacOS Mojave, but for some reason, any version beyond this, displays and error that the file cannot be found.

Code used:

  currentUser=$( stat -f "%Su" /dev/console )

  sudo -u "$currentUser" /usr/bin/open -b com.microsoft.outlook "mailto:$supportEmail?subject=Support Request -  

  $currentUser ($computerName - $serialNumber)&body=$displayInfo"

 

It seems to be an issue with spaces in the displayInfo section, because if I remove the &body=$displayInfo section and add %20 into the spaces of the Subject Line (after making it more simple) it seems to work.

 "mailto:$supportEmail?subject=Support%20Request"

Error Received:

  The Files /Users/{username}/Desktop/mailto:.... does not exist.

I have tried moving the mailto: to outside the quotes, and convert these to single quotes, still not working.

This is becoming very frustrating, and would love someone in our community to help me out.

1 ACCEPTED SOLUTION

talkingmoose
Moderator
Moderator

Thanks for the feedback on this. I've just updated the script to URL encode the subject and message for email. Newer versions of macOS no longer seem to do this automatically.

You'll find the updated script here: https://github.com/talkingmoose/Jamf-Scripts/blob/master/Computer%20Information.bash

View solution in original post

4 REPLIES 4

DBrowning
Valued Contributor II

This would change things a little bit for you, but I have a script that sends an email using osascript.  This will open the email window and the user just has to click send.

osascript -e 'tell app "Microsoft Outlook"' -e 'set newMessage to make new outgoing message with properties {subject:"Whatever you want for subject"}' -e 'make new recipient at newMessage with properties {email address:{name:"NAME", address:"EMAIL@COMPANY.COM"}}' -e 'set content of newMessage to "BODY OF MESSAGE. CAN INCLUDE VARIABLES. SN: '$sn'"' -e 'open newMessage' -e 'end tell'
	

 

Hi,

Thank you for your response, I did try this also... It comes up with a security message saying it cannot be sent to Microsoft Outlook.

 

Thanks

Ben

talkingmoose
Moderator
Moderator

Thanks for the feedback on this. I've just updated the script to URL encode the subject and message for email. Newer versions of macOS no longer seem to do this automatically.

You'll find the updated script here: https://github.com/talkingmoose/Jamf-Scripts/blob/master/Computer%20Information.bash

Hey,

Great update to your script.  Works perfectly, now for me to go and break it by adding the extra bits of information I need.  Thank you.

 

Yours

 

Ben