Use AppleScript to open specific smart mailbox

Is it possible to use AppleScript to open/display a specific smart mailbox in Mail?


I have a Microsoft Exchange email account in Mail, with multiple mailboxes and emails stored in each. The name of each mailbox corresponds with a name of a certain record/entry in a FileMaker Pro 13 database. I would like to have a button in each record/entry in the FileMaker database, that when clicked runs an AppleScript that will open/display the mailbox in Mail for that particular record.


For reference, I am running FileMaker Pro 13, Mail (v9.3) on OS X El Capitan (v10.11.4).

iMac (Retina 5K, 27-inch, Late 2015), OS X El Capitan (10.11.4)

Posted on May 17, 2016 9:38 AM

Reply
3 replies

May 19, 2016 11:37 PM in response to Opscen

Is it possible to use AppleScript to open/display a specific smart mailbox in Mail?


I know nothing about Microsoft Exchange or FileMaker Pro.

Nevertheless, the following GUI script can select a smart mailbox under OS X 10.11.3.


set theSmartMailboxName to "TEST" -- replace "TEST" with any name of your choice


tell application "Mail"

launch

activate

tell application "System Events" to tell process "Mail"

keystroke "0" using {command down}

if subrole of window 1 is "AXFloatingWindow" then clickbutton 1 of window 1

if not (existsscroll area 1 of splitter group 1 of window 1) then

keystroke "m" using {shift down, command down}

end if

tell outline 1 of scroll area 1 of splitter group 1 of window 1

select (row 1 whose value of text field 1 of UI element 1 is theSmartMailboxName)

end tell

end tell

end tell

Also have a look to this article.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Use AppleScript to open specific smart mailbox

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.