Action in mail if subject content specify word?

No with regular action in mail, but with a applescript, I need a script look only the new and unread mail and execute a beep if there is a specify word in subject when applescript run. :wink:


define a rule and attach this script

using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		repeat with eachMessage in theMessages
			tell application "Mail"
				if content of eachMessage contains "mySpecialWord" then beep
			end tell
		end repeat
	end perform mail action with messages
end using terms from

Oh thanks StefanK,

but I no want define a rule, because I need only when script run (and mySpecialWord is a variable in script)
When script run it check for new mail for account (myaccount) (until 5 minutes for example)
if content of subject (in the new mail in this 5 minutes) contains “mySpecialWord” then beep.


allright, then try this (change “myAccount” to the name of your desired account.
It checks all unread meaages to match with mySpecialWord

set mySpecialWord to "mySpecialWord"
tell application "Mail"
	repeat with theMessage in (get messages of mailbox "INBOX" of account "myAcccount" whose read status is false)
		if content of theMessage contains mySpecialWord then beep
	end repeat
end tell

It’s perfect!