Applescript not quitting application after tell
Hello everyone i just have a quick applescript question.
Im trying to write a script that will check mail for new messages fitting certian peramiters and reterns something if it is successful, after checking id like it to quit Mail.
It checks the messages just fine, and returns information as desired, though for whatever reason it doesnt quit.........
Here is a quick example
in this its checking for message subjects containing certain text and reterns the subject line of those that do
tell application "Mail"
check for new mail
repeat until (background activity count) = 0
delay 0.5 --wait until all new messages are in the box
end repeat
repeat 4 times
try
return subject of (first message of inbox whose read status is false and sender contains "SUBJECT_TEXT_HERE")
end try
end repeat
quit
end tell
Ive also tried adding "tell application "Mail" to quit" at the end of the initial tell, but that doesnt work either
Ive looked around and cant seem to find another person with this issue.....
and i really have no idea what it could be
Im sure its just a tiny mistake im making, but i cant figure out where
Any ideas you have are greatly appriciated!
~p
MacBook Pro, OS X Mountain Lion (10.8.3), 2.3 GHz i5, 8Gb DDR3, 1T HDD