This works in the AppleScript Editor:
tell application "Microsoft Outlook" to activate
tell application "System Events"
click menu item "Block Sender" of menu "Junk Mail" of menu item "Junk Mail" of menu "Message" of menu bar item "Message" in menu bar 1 of process "Outlook"
end tell
However, when I move this script to Outlook's script folder (~/Library/Application Support/Microsoft/Office/Outlook Script Menu Items/
) and attempt to run it from Outlook's script menu, I get an error:
System Events got an error: Can't get menu bar 1 of process "Outlook". Invalid index.
Should I not be using System Events
?
application process "Microsoft Outlook"
. – user309603