From MacOSXHints.com: This script was posted by a user who was frustrated at digging through Mail.app’s preferences to turm image viewing on/off.
OS version: OS X
tell application "Mail"
set currentState to download html attachments
if currentState = false then
set newState to true
else
set newState to false
end if
set download html attachments to newState
display dialog ¬
"Download HTML attachments set to \"" & ¬
newState & "\"." buttons {"OK"}
end tell