Outlook 2016 for Mac won’t return “current messages” from main window

applescriptemailms office

In Outlook 2011 for Mac, I was able to use an AppleScript to move currently-selected messages from the main Outlook window. The script started like this:

tell application "/Applications/Microsoft Outlook.app"
    set myMessages to current messages

This worked regardless of whether there was a Reminder pop-up window currently on the screen or not.

Starting with the Outlook for Mac Preview, and continuing with the final 2016 version, this script now only works when the Reminder pop-up window is not on screen. If the Reminder window is on screen, the script treats whatever items currently appear in the pop-up window as the current messages, even if I first instruct Outlook to make the main mail window active. (I suspect this may have something to do with the fact that the Reminder window is always "on top" regardless of what you have selected.) As a result, the script fails when the Reminder pop-up is open (i.e., it indicates that no mail messages are currently selected).

Are there any suggestions for how I can force Outlook to return the set of messages selected in the main mail window rather than the Reminder pop-up?



Building off of the answer below, to minimize the inconvenience of closing the Reminders window, you can add the following code before the call to "current messages":

--Workaround to fix Outlook 2016 Reminders window bug, part 1
set windowClosed to false
if "Reminder" is in (name of the front window) then
    set windowClosed to true
    close front window
end if

And then add this at the end of the script, to re-open the Reminders window if it was closed by the script:

--Workaround to fix Outlook 2016 Reminders window bug, part 2
if windowClosed is true then
    tell application "System Events" to keystroke "9" using command down
end if

Best Answer

I'm an applescript novice, but I was able to add the following code to close the reminders window if it was up when the script ran:

-- close the reminders window if it is open
set winName to name of the front window
if "Reminders" is in winName then
    close front window
end if