Sending Emails via JSS

sgoetz
Contributor

Im curious is there away to put variables in a email. For example. I want to say something like this.

Records show you have %computername%. If you still have this computer please plug it into the network so it can get updates.

11 REPLIES 11

emily
Valued Contributor III
Valued Contributor III

Computer name is one of the default variables in the JSS. So it would just be $2.

I have a policy in our Self Service app that helps a user auto-generate a help desk ticket by opening their default mail client. The subject is:

"Hello, my username is $3 and my computer's name is $2. I need help with ... "

EliasG
Contributor

@emilykausalik how did you do that?

emily
Valued Contributor III
Valued Contributor III

I created a Self Service policy that runs this script:

#!/bin/sh

#  SendHelpDeskRequest.sh
#  Opens user's default mail client to send an email to the HelpDesk. Hooray automation!
#
#  Created by Emily Kausalik on 10/3/14.
#  

# getting user information
# default parameters from the JSS
computername=$2
username=$3

# set email information
subject="Request Subject"
body="Hello, my username is $3 and my computer's name is $2. I need help with ... "

# send email through default mail client
open "mailto:helpdesk@awesomecompany.com?subject=$subject&body=$body"

All is does is create a draft email in the default client on the machine. It gets the ball rolling.

sgoetz
Contributor

Thank you for that information. That works if you are using a script to do that. However, I am using the GUI version to send the email via JSS. For example. Do a search for a criteria, click Actions - > Click Send Email -> Right email with variables.

mm2270
Legendary Contributor III

Don't think there's a way to do it by using the GUI method from the JSS. I think that simply sends out a statically messaged email to the user who is defined in the Location setting for the Mac.

Just curious, but if you're locating these Macs via search, you could also build a quick Smart Group using the same criteria and add them to a one time policy that uses a scripted method. Or better yet, if its something that you want automated, set up a once per computer policy, so when a Mac falls into that group, they get sent an email. That would make more sense to me on the surface. Is there a requirement to do a manual search and email blast?

sgoetz
Contributor

Thank you guys, looks like I will have to go the script route. I was just hoping the GUI part worked, that way I don't have to always write a different script everytime my comm. dept wants to send out some email to our mac users. So I was just going to give them access via the GUI to do it.

mm2270
Legendary Contributor III

You might want to look at the thread on this older Feature Request.
https://jamfnation.jamfsoftware.com/featureRequest.html?id=611
Some ideas are tossed around on how to get the client to email themselves (but appear as if coming from something else) when they become part of a Smart Group. It might help.

JMenacker
New Contributor III

@emily this script is exactly what I am looking for but I am not able to get it to open Outlook. I already have Outlook.app set as the default handler for email. Any suggestions? Is there a simple way for me to modify what you have there to tell it to Open Outlook before applying the automated template message?

sanbornc
New Contributor III

@JMenacker and @emily did you ever figure out how to use Outlook? Or to force the script to use Outlook instead of the default Mail app?

JMenacker
New Contributor III

@sanbornc this is what I've been using for now until I can take the time to find something better looking:

#!/bin/sh

/usr/bin/osascript <<EOF
tell application "Microsoft Outlook"
    activate
    set sendToAddress to "youremailaddresshere@yourcompany.com"
    set theMessage to make new outgoing message with properties {subject:"Request for Help via Self Service"}
    make new recipient at theMessage with properties {email address:{address:sendToAddress}}
    open theMessage
end tell
EOF

It works how we need it and have not had any complaints from customers. Hope this helps!

sanbornc
New Contributor III

@JMenacker @emily Thanks for that. That works, but I would be interested in having the email pre-populate the computer name and username that Emily was alluding to in her script up above. She mentioned "Default Parameters" from the JSS as the source for the $2 and $3. How do I pass that information through to the Outlook email and where do I go to find out that those "Default Parameters" are?