Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29748

Getting at a Message from a Mail Rule in Applescript

$
0
0

As an excuse to learn Applescipt, I writing a script to be attached to a Mail rule to filter messages. I scrounged around and put together this much code:

on perform_mail_action(theData)
    tell application "Mail"
        set theSelectedMessages to |SelectedMessages| of theData
        set theRule to |Rule| of theData
        repeat with a from 1 to count theSelectedMessages
            set theMessages to selection
            set theMessage to item 1 of theMessages
        end repeat
    end tell
end perform_mail_action

I would have thought the rule would only pass one message, but you never know so the repeat makes sense. I presume "selection" is a pointer to an item in theSelectedMessages. What seems strange is "set theMessage to item 1 of theMessages". I would have thought you would code "set theMessage to selection". I want to get to the body, "content" of the message to test for certain words.

Thanks for any help, Curt


Viewing all articles
Browse latest Browse all 29748

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>