My goal is to search mail for all messages in the inbox from a sender, simply by selecting one email and enabling the script. I have succeeded in writing a script that opens all messages from a selected sender, but I can't filter the mailbox view to all messages from a sender. Is there a way to enable the search or filter command in Mail via AppleScript? I've attached my code below:

tell application "Mail"
    if not (get selection) is {} then
        set theMsg to item 1 of (get selection)
    end if
    tell theMsg
        set theSender to its sender
    end tell
    set SendSend to (extract address from theSender)
    open (every message of inbox whose sender is equal to theSender)
end tell


This question is similar in nature to Use AppleScript to search for message by subject


You must log in to answer this question.

Browse other questions tagged .