0
votes

I would like to block a spammer's address using AppleScript.

With the Inbox message selected, I execute this script:

tell application "System Events"

    click menu item "Block Sender" in menu item "Junk Mail" in menu bar item "Message" in menu bar 1 of application process "Microsoft Outlook"

end tell

Which results in this error:

System Events got an error: Can’t get menu item "Junk Mail" of menu bar item "Message" of menu bar 1 of application process "Microsoft Outlook".

The Junk Mail menu has a submenu:

enter image description here

The AppleScript Editor has been granted access to control my computer:

enter image description here

What am I missing?

1

1 Answers

0
votes

I can't really test it with Outlook, but you missed to tell the menus "Message" and "Junk Mail" of the menu items:

tell application "System Events"

    click menu item ¬
         "Block Sender" in menu ¬
         "Junk Mail" in menu item ¬
         "Junk Mail" in menu ¬
         "Message" in menu bar item ¬
         "Message" in menu bar 1 ¬
         of application process "Microsoft Outlook"

end tell