MS Outlook "current messages" not working?

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:

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 •", "", "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.

This works fine for me. You probably have the abomination called “New Outlook” on. You have to revert to the Outlook version that has a working AppleScript dictionary.

1 Like

name is a property… one of several which windows possess.

Generally, you can ask for the properties of any object:

tell application "Microsoft Outlook" to properties of windows
--> {{zoomed:false, miniaturized:false, name:"Inbox", ¬
object:missing value, floating:false, modal:false, ¬
miniaturizable:true, class:window, closeable:true, ¬
resizable:true, visible:true, zoomable:true, id:669, ¬
bounds:{23, 22, 1258, 768}, index:2.147483647E+9, titled:true}}

For my ancient version of outlook (2011 or v14.7), only one window seems to be open, so it returns a list of one record. This might give you a bit more insight than just deriving the name. FWIW, some apps do invisible window shenanigans. Apparently, outlook has become one of those. I don’t think it should be a cause for concern.

Is that a setting, or an entirely different product/purchase?

It’s a setting:

I meant to include that window properties in my post. One was a skinny vertical window, starting at the some top-left coordinate as the main window, with bounds something like {0,0,900,900}. I don’t remember the other one.
The reason I thought they might cause issues is because of the links I shared, where people were getting a failure of current messages when a reminders window was open at all, even though the “main window” was supposedly frontmost.
Interestingly, when I restart Outlook today, there is only a single window. But, it has interesting properties (I swapped in a fake email for the window title here):

{{closeable:true, zoomed:false, class:window, index:-1, visible:true, name:"Inbox •", modal:false, object:missing value, miniaturizable:true, titled:true, id:1553, floating:false, miniaturized:false, resizable:true, bounds:{113, 105, 1492, 797}, zoomable:true}}

I see that the index is -1, which seems odd.

Seems to me that @bwill is right - I’ll try “Legacy Outlook”.

When dealing with an item index, in this case of a window, -1 means the last window.

tell application "Finder" to name of Finder window -1
--> "Documents"
tell application "Finder" to get name of last window
--> "Documents"

Oh, and the bounds that you mention —{0,0,900,900}— are actually a 900 pixel square that begins at the top left corner. Normally you can’t put a window that high as the menu bar is 22 pixels high and you can’t move things up there. And with a retina screen, the 900 pixels is actually 1800. By the way, the pattern is {L,T,R,B}. I always use the word LaTRoBe to make it easy to recall.

Occasionally, as windows move around so easily, it can be worth getting some more reliable measure than the index. The id is unique and should remain so, even after a name change. Unless I’m being lazy, I sometimes switch from using a window’s index to its id or name right after opening/creating it.

As to outlook, I thought I read somewhere that MS had released an update that finally made things better again. Maybe they were just planning to.

I’m using Monterey and Outlook 16.75.2 (OLD version setting) and this also works fine for me.