AppleScript and Mail.app: checking if new messages contain a string
applescript, email
Solution
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
try
return subject of (first message of inbox whose read status is false and subject contains "New newsletter built by ")
end try
end tell
Problem
I'm writing a script to check if a particular web form has been submitted. The script so far reads thusly: ``` tell application "Mail" check for new mail set newmail to get the unread count of inbox repeat with msg in newmail if msg's subject contains "New newsletter built by" then return msg's subject end if end repeat end tell ``` I've got an unread email in my inbox for the script to work with, but I still get an error: ``` error "Mail got an error: Can’t make 1 into type specifier." number -1700 from 1 to specifier ``` Any help at all will be appreciated. Cheers!