Outlook Auto Download Settings

dan-snelson
Valued Contributor II

We were recently asked to verify and configure Outlook’s automatic downloading of pictures from the Internet:
Outlook 2011 / 2016 > Preferences > Reading > Security
2fc3bb57fdb24fc28bf7ac80851f6e8c

The initial plan was to use a Custom Configuration Profile for the “com.microsoft.Outlook” domain (note the unique spelling of automatically):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>AutomaitcallyDownloadExternalContent</key>
        <integer>1</integer>
    </dict>
</plist>

However, in limited testing, the Custom Configuration Profile yielded unpredictable results on OS X 10.11.3 (i.e., Outlook 2016 crashed on launch; Outlook 2011’s GUI always displayed as expected, but user interaction resulted in the .plist’s values being modified).

A couple of Extension Attributes and a Bash script later — which uses Parameter 4 for the desired setting — and we’re set.

Outlook 2011 Download Content Extension Attribute

#!/bin/sh
####################################################################################################
#
# ABOUT
#
#   Extension Attribute to read: Outlook 2011 > Preferences > Reading > Security >
#   Automatically download pictures from the Internet
#
####################################################################################################
#
# HISTORY
#
#   Version 1.0, 27-Jan-2016, Dan K. Snelson
#
####################################################################################################

# Variables
loggedInUser=`/usr/bin/who | /usr/bin/grep console | /usr/bin/awk {'print $1'}`
testFile="/Users/${loggedInUser}/Library/Preferences/com.microsoft.Outlook.plist" # Outlook 2011

if [ -f $testFile ]; then
    DownloadExternalContentStatus=`/usr/bin/defaults read ${testFile} AutomaitcallyDownloadExternalContent`

    case "${DownloadExternalContentStatus}" in
        0)
            Status="In all messages"
        ;;
        1)
            Status="In messages from my contacts" 
        ;;
        *)
            Status="Never"
        ;;
    esac

    echo "<result>${Status}</result>"

else

    echo "<result>Not Found</result>"

fi

exit 0

Outlook 2016 Download Content Extension Attribute

#!/bin/sh
####################################################################################################
#
# ABOUT
#
#   Extension Attribute to read: Outlook 2016 > Preferences > Reading > Security >
#   Automatically download pictures from the Internet
#
####################################################################################################
#
# HISTORY
#
#   Version 1.0, 27-Jan-2016, Dan K. Snelson
#
####################################################################################################

# Variables
loggedInUser=`/usr/bin/who | /usr/bin/grep console | /usr/bin/awk {'print $1'}`
testFile="/Users/${loggedInUser}/Library/Containers/com.microsoft.Outlook/Data/Library/Preferences/com.microsoft.Outlook.plist" # Outlook 2016


if [ -f $testFile ]; then
    DownloadExternalContentStatus=`/usr/bin/defaults read ${testFile} AutomaitcallyDownloadExternalContent`

    case "${DownloadExternalContentStatus}" in
        0)
            Status="In all messages"
        ;;
        1)
            Status="In messages from my contacts" 
        ;;
        *)
            Status="Never"
        ;;
    esac

    echo "<result>${Status}</result>"

else

    echo "<result>Not Found</result>"

fi

exit 0

Outlook_Auto_Download_Settings.sh

When editing Computer Management > Scripts, manually set Options > Parameter 4 to: Setting (All | Contacts | Off)

b2b20f2148b24e4f8a28db7deaa292a0

After adding the script to a Policy, specify “All”, “Contacts”, or “Off” for Parameter 4. (Default is “Off” when Parameter 4 is left blank.)

#!/bin/sh
####################################################################################################
#
# ABOUT
#
#   Configure defaults for Microsoft Outlook:
#   * Specify automatic downloading of pictures from the Internet
#
####################################################################################################
#
# HISTORY
#
#   Version 1.0, 28-Jan-2016, Dan K. Snelson
#
####################################################################################################
# Import logging functions
source /path/to/client-side/logging/script/ScriptLog.sh
####################################################################################################

ScriptLog "#### Configure Microsoft Outlook's automatic downloading of pictures from the Internet ####"

# Variables
loggedInUser=`/usr/bin/who | /usr/bin/grep console | /usr/bin/awk {'print $1'}`
downloadSetting="$4"  # All | Contacts | Off (setting for automatic downloading of pictures from the Internet)


Outlook2011(){

    testFile="/Users/${loggedInUser}/Library/Preferences/com.microsoft.Outlook.plist" # Outlook 2011

    if [ -f $testFile ]; then

        # Capture the current state
        DownloadExternalContentState

        ScriptLog "* Microsoft Outlook 2011 Automatic Download Current Setting: ${Status}"

        case "${downloadSetting}" in
            "All")
                        sudo -u ${loggedInUser} /usr/bin/defaults write ${testFile} AutomaitcallyDownloadExternalContent 0
            ;;
            "Contacts")
                        sudo -u ${loggedInUser} /usr/bin/defaults write ${testFile} AutomaitcallyDownloadExternalContent 1
            ;;
            *)
                        sudo -u ${loggedInUser} /usr/bin/defaults delete ${testFile} AutomaitcallyDownloadExternalContent
            ;;
        esac

        # Capture the updated state

        DownloadExternalContentState

        ScriptLog "* Microsoft Outlook 2011 Automatic Download Updated Setting: ${Status}"

    else

        ScriptLog "Did not find a Microsoft Outlook 2011 preference file for ${loggedInUser}"

    fi
}



Outlook2016(){

    testFile="/Users/${loggedInUser}/Library/Containers/com.microsoft.Outlook/Data/Library/Preferences/com.microsoft.Outlook.plist" # Outlook 2016

    if [ -f ${testFile} ]; then

        # Capture the current state
        DownloadExternalContentState

        ScriptLog "* Microsoft Outlook 2016 Automatic Download Current Setting: ${Status}"

        case "${downloadSetting}" in
            "All")
            if [ "${Status}" == "Never" ]; then
                sudo -u ${loggedInUser} /usr/libexec/PlistBuddy -c "Add :AutomaitcallyDownloadExternalContent integer 0" ${testFile}
            else
                sudo -u ${loggedInUser} /usr/libexec/PlistBuddy -c "Set :AutomaitcallyDownloadExternalContent 0" ${testFile}
            fi          
            ;;

            "Contacts")           
            if [ "${Status}" == "Never" ]; then
                sudo -u ${loggedInUser} /usr/libexec/PlistBuddy -c "Add :AutomaitcallyDownloadExternalContent integer 1" ${testFile}
            else
                sudo -u ${loggedInUser} /usr/libexec/PlistBuddy -c "Set :AutomaitcallyDownloadExternalContent 1" ${testFile}
            fi
            ;;

            *)
                sudo -u ${loggedInUser} /usr/libexec/PlistBuddy -c "Delete :AutomaitcallyDownloadExternalContent" ${testFile}
            ;;
        esac

        # Reload preferences
        /usr/bin/killall -u ${loggedInUser} cfprefsd

        # Capture the updated state
        DownloadExternalContentState

        ScriptLog "* Microsoft Outlook 2016 Automatic Download Updated Setting: ${Status}"

    else

        ScriptLog "Did not find a Microsoft Outlook 2016 preference file for ${loggedInUser}"

    fi
}



DownloadExternalContentState() { # Capture the current state
DownloadExternalContentStatus=`/usr/bin/defaults read ${testFile} AutomaitcallyDownloadExternalContent`

case "${DownloadExternalContentStatus}" in
    0)
        Status="In all messages"
    ;;
    1)
        Status="In messages from my contacts" 
    ;;
    *)
        Status="Never"
    ;;
esac
}



Outlook2011

/bin/sleep 5

Outlook2016



/bin/echo "${Status}"



exit 0
2 REPLIES 2

ocla__09
Contributor

Hello @dan.snelson

I am a little confused by line 17:
source /path/to/client-side/logging/script/ScriptLog.sh

Can you elaborate on this part a bit?

dan-snelson
Valued Contributor II

@ocla&&09

Below is what we're currently installing on clients when enrollment is complete to:
/path/to/client-side/logging/script/ScriptLog.sh

#!/bin/sh
####################################################################################################
#
# ABOUT
#
#   Standard logging functions which are imported into other scripts
#
####################################################################################################
#
# HISTORY
#
#   Version 2.0, 13-Oct-2015, Dan K. Snelson
#
####################################################################################################

# LOGGING

# Logging variables
    logFile="/var/log/com.company.log"
    alias now="date '+%Y-%m-%d %H:%M:%S'"

# Check for / create logFile
    if [ ! -f "${logFile}" ]; then
        ### logFile not found; Create logFile
        /usr/bin/touch "${logFile}"
    fi

# Save standard output and standard error
    exec 3>&1 4>&2
# Redirect standard output to logFile
    exec 1>>"${logFile}"
# Redirect standard error to logFile
    exec 2>>"${logFile}"
#
# Example
#   /bin/echo "`now` Hello, world!" >> $logFile
#
# Enable all logging from this point forward
#   set -xv; exec 1>>"${logFile}" 2>&1
#

# Logging Function
# From rtrouton; see https://github.com/rtrouton/CasperCheck/blob/master/script/caspercheck.sh
ScriptLog(){

    DATE=`date +%Y-%m-%d %H:%M:%S`
    LOG="$logFile"

    /bin/echo "$DATE" " $1" >> $LOG
}

####################################################################################################