Posted on 08-18-2018 03:40 PM
Hello all,
I did some research into scripting, specifically the Outlook dictionary, when I was first developing the signature and how to create it. That is now working great and we are able to deploy a solution that removes any old signatures and adds a new signature, however I am running into an issue with setting it as the default in Outlook. This is my script:
#!/usr/bin/osascript
--Looks up username for dscl. No "whoami" because when deployed its run as root.
set user to do shell script "stat -f '%Su' /dev/console"
--Grabs information from AD and selects the needed part
set fullname to do shell script "dscl . -read /Users/" & user & " RealName | awk -F 'RealName:' '{ print $1 }'"
set email to do shell script "dscl . -read /Users/" & user & " EMailAddress | awk '{ print $2 }'"
set phonenumber to do shell script "dscl . -read /Users/" & user & " PhoneNumber | awk -F 'PhoneNumber:' '{ print $1 }'"
set jobtitle to do shell script "dscl . -read /Users/" & user & " JobTitle | awk -F 'JobTitle:' '{ print $1 }'"
--Opens Microsoft Outlook
tell application "Microsoft Outlook"
--Hides Microsoft Outlook
set miniaturized of window 1 to true
--Deletes Current Signature
delete every signature
--Creates HTML signature using html code
make new signature with properties {name:"Signature", content:"HTML GOES HERE"}
end tell
--Sets the default signature.
tell application "Microsoft Outlook"
activate
end tell
tell application "System Events"
tell process "Microsoft Outlook"
tell menu bar 1
tell menu bar item "Outlook"
tell menu "Outlook"
click menu item "Preferences..."
end tell
end tell
end tell
end tell
end tell
tell application "System Events"
tell process "Microsoft Outlook"
click button 8 of window "Outlook Preferences"
end tell
end tell
tell application "System Events"
tell process "Microsoft Outlook"
tell window "Signatures"
tell group 2
set Preset to get value of pop up button 2
if Preset is equal to "Signature" then
--do nothing
else
if Preset is equal to "None" then
click pop up button 2
delay 0.5
keystroke (ASCII character 31) -- down arrow key
delay 0.5
keystroke (ASCII character 3) -- enter key
delay 0.5
else
click pop up button 2
delay 0.5
keystroke (ASCII character 31) -- down arrow key
delay 0.5
keystroke (ASCII character 3) -- enter key
delay 0.5
end if
end if
set Preset to get value of pop up button 1
if Preset is equal to "Signature" then
--do nothing
else
if Preset is equal to "None" then
click pop up button 1
delay 0.5
keystroke (ASCII character 31) -- down arrow key
delay 0.5
keystroke (ASCII character 3) -- enter key
delay 0.5
else
click pop up button 1
delay 0.5
keystroke (ASCII character 31) -- up arrow key
delay 0.5
keystroke (ASCII character 3) -- enter key
delay 0.5
end if
end if
end tell
end tell
end tell
end tell
tell application "Microsoft Outlook" to quit
Like I said this works perfectly well to get the user's name, then look at information that we get from Active Directory to pull the Name, Job Title, Phone Number, and Email. Then those are piped into the HTML and it generates a custom signature per user.
The last part where it says "Sets the default signature" will work assuming that "JamfAgent" is in the Privacy / Accessibility area in System Preferences, however it is not for most of our users. I found a command that you can issue to edit the TCC.db and add it, however apparently since Sierra it has been a part of SIP. I went looking into the Outlook preferences to see if I could script it that way and I couldn't find anything.
Does anyone have any insight or can think of anything that I am missing to set this as the default signature?
Thank you,
Austin
P.S. I have put in a feature request with Microsoft that they add something like this to their dictionary and will update if I hear anything back :)
Posted on 05-09-2024 11:38 AM
@Austin_Hicks I was able to apple script the outlook signature with part of your help but do you know if images work with signatures? It seems like the only way to point to an logo is with a URL instead of a filepath.
Posted on 05-09-2024 11:38 PM
Hello @agent23tv,
As it turns out I am no longer with that company and also no longer a JAMF Admin. I will do my best to help with what I do remember, which is the following:
- We were able to use an image from a file path, but we ran into a different problem. It was that if we did a local file, it attached the file to every email. So it looked like every email sent and received had an attachment, which was not a valid solution.
- We ended up using a logo png from a URL that was loaded into Akamai so that it was pretty much always available through their CDN.