set msgFile to alias "OS_X:Users:lutherfuller:Desktop:UI scripts:Kids Book Sale -- 4 Days Only! 0.emlx"
tell application "Mail"
activate
close every window
set download html attachments to true
open msgFile
set download html attachments to false
set winName to (name of window 1)
-- close window winName -- this command works here, but ...
delay 1
-------------------
tell application "System Events"
-- UI elements enabled is true. Set manually.
tell process "Mail"
keystroke "p" using {command down}
delay 1
click menu button "PDF" of sheet 1 of window 1
delay 1
click menu item "Save as PDF…" of menu of menu button "PDF" of sheet 1 of window 1
delay 1
click button "Save" of window "Save" -- save location has been manually set to Desktop
end tell
end tell
-------------------
close window winName -- but this command does NOT work.
end tell