There seems to be a bug in Microsoft Outlook 2021 (v 16.75.2), where the current messages command, found in the script dictionary for Outlook, does not work.
When I have the main window open, with one or multiple messages selected, I get an empty list for that command:
tell application "Microsoft Outlook"
current messages
--> {}
end tell
I saw some old posts online that having some window open in Outlook that did not contain messages could cause this. See:
- email - Outlook 2016 for Mac won't return "current messages" from main window - Ask Different
- scripting Outlook 2016
However, in my case, the only visible window is the “main” window containing my accounts, Inbox, and message preview columns. I checked the “Windows” menu in Outlook, and it shows only that window.
Then, I thought I’d check what AppleScript sees, as far as what windows Outlook had open, so I ran this:
tell application "Microsoft Outlook"
name of windows
end tell
The result was:
{"Inbox • dan@example.com", "", "Untitled"}
So! Apparently there are two invisible windows ALSO open in Outlook that I have no control over.
Trying to use AppleScript to close window 2
or close window 3
returns no error (nor any result at all), but the 3 windows (the 2nd and 3rd invisible) persist.
Now, perhaps these windows are harmless. The 1st window is listed as the window in which I have messages selected. However, my suspicion is that something about the existence of these other two windows is causing a problem.
I also tried this with Outlook in Full Screen mode. Same results.
Note that I have also tried the selection command. It has similar, but different results: missing value. That is true whether I have messages selected in a mailbox in the frontmost window, or a single message window open.
Has anyone else been able to use the current messages AppleScript command with this version of Outlook? I’m hoping to be able to script Outlook, but this might throw a wrench in things. Any insight would be appreciated.