Trying to create a script meant to add selected message(s) to my eMail spam delete rule. Here’s what I have written but I cannot seem to make it work. I believe the idea is good, but I cannot get the script to compile so I am not sure it will work as intended. Any ideas or assistance will be greatly appreciated…
use AppleScript version “2.8 or later”
set theProperties to {}
tell application id “com.apple.mail” – Mail.app
set theMessages to the selection
repeat with i in theMessages
set theSender to sender of currentMessage as string
set oldDelimiters to AppleScript’s text item delimiters
set AppleScript’s text item delimiters to {“@”}
try
set theDomain to the second text item of theSender
set AppleScript’s text item delimiters to “”
if theDomain contains “>” then
set theDomain to leftStringFromRight(theDomain, “>”) of theScript
end if
repeat
if theDomain contains “.” then
set theDomain to leftStringFromRight(theDomain, “.”) of theScript
else
exit repeat
end if
end repeat
end try
tell rule “Delete”
repeat with i in theDomain
rule condition at end of rule conditions with properties {rule type:from header, qualifier:does contain value, expression:i}
end repeat
end tell
end repeat
end tell