I may be missing something about OS X Mail, but I often find that I have a largish number of email windows open, and want to close them all without closing the Inbox window.
Would not be surprised to learn that there is already a keystroke, but in the meanwhile, here is a 土办法 (inelegant hack : - ) for 10.10 or 10.11 (uses a JS for Automation action)
The cheat method for this is generally: Close All Windows, Open Message Viewer. Command-Shift-W, Command-0.
@ComplexPoint’s method is more elegant of course, but for those folks lacking the scripting skills, the cheat method is pretty effective (or they can of course ask here and some kind fellow like @ComplexPoint would no doubt help them out!)
Since Yosemite scripting in Mail has become quite flakey. A number of things which used to work are now broken. My particular issue is closing the preview window, but that’s another story.
tell application "Mail"
close (windows whose name does not start with "Inbox")
end tell
Leave any and all message-viewers open:
tell application "Mail"
set msgViewerList to name of message viewers
repeat with theWindow in (get windows)
if name of theWindow is not in msgViewerList then close theWindow
end repeat
end tell