Applescript Access to Outlook New Mail menu bar

I’d like to workaround a limitation with Outlook which is of it not allowing me to set a delay all emails sent by x minutes. A way I thought about working around this is to use Alfred Worklfows Hotkey trigger to be run when I decide to send a message. This trigger actions an Applescript to navigate to the menu bar of the new message window go to Draft and click Send Later…

The blocker I stumbled on is that the menu bar doesn’t sees the “Draft” menu bar item because it is not available on the main outlook window, but only for the new message window.

Because of this when I try:
tell application “System Events”
tell process “Outlook”
tell menu bar 1
tell menu bar item “Draft”
click menu item “Send Later…”
end tell
end tell
end tell
end tell

I get

“execution error: System Events got an error: Can’t get menu item “Send Later…” of menu bar item “Draft” of menu bar 1 of process “Outlook”.”

So, the question is, how do I get to the right menu bar which is not the main window? I’ve tried the obvious thing which is to tell menu bar 2, but none of that worked. I’ve also tried exploring the app via Accessibility Investigator, but there I also couldn’t find the menu bar.

Any ideas?

Many thanks for your help.

Hi there,

Welcome to MacScripter! :slight_smile:

You may have already found a solution but if not give this a try.
I’ve tested it with a new email window open in Outlook and it works for me.
You may want to add some error handling in case any anomalies crop up.

The ‘To:’ and ‘Subject’ were pre-filled. I’d also put something in the body of the email.
As you can see the script allows you to specify how many hours and minutes you’d like to add to the current time.


set minsToAdd to 10
set hrsToAdd to 1

set sendAtTime to (current date) + (hrsToAdd * hours) + (minsToAdd * minutes)

set newMins to minutes of sendAtTime
set newHrs to hours of sendAtTime


activate application "Microsoft Outlook"

tell application "System Events"
	tell process "Microsoft Outlook"
		
		click menu item "Send Later..." of menu 1 of menu bar item "Draft" of menu bar 1
		
		delay 0.5
		keystroke tab
		keystroke tab
		
		delay 0.5
		keystroke tab
		keystroke (item 1 of (newHrs as text))
		keystroke (item 2 of (newHrs as text))
		keystroke tab
		
		delay 0.5
		keystroke (item 1 of (newMins as text))
		keystroke (item 2 of (newMins as text))
		
		click button "Send" of sheet 1 of front window
		
	end tell
end tell

HTH