Hopefully, I can explain what I am attempting to achieve. I have an email address designated for SMS ([email protected]) This account gets check via Mail (apple V13). I have a rule that every message does an Applescript as follows:
using terms from application "Mail"
on perform mail action with messages newMessages
repeat with newMessage in newMessages
tell application "Mail"
set theText to ""
set theSubject to ""
repeat with theMessage in selectedMessages
set theText to theText & (content of theMessage) as string
set theSubject to theSubject & (subject of theMessage) as string
tell application "Messages"
activate --steal focus
set targetBuddy to theSubject
set targetService to id of service "SMS"
set textMessage to theText
set theBuddy to buddy targetBuddy of service id targetService
send textMessage to theBuddy
end tell
end repeat
end tell
end repeat
end perform mail action with messages
end using terms from
Unfortunately it does not work and for the life of me I dont understand why.
Could I ask for some assistance?
tell
block inside a Mailtell
block, which is going to be a potential cause for problems. I'd suggest taking it outside the entireon perform mail action
handler, and sticking it in its own handler that you can call. I can't say for sure that it's definitely the source of your problem, but you also don't say anything about how this script fails to work, i.e. what should it do, what does it do currently, and what errors arise and where in the script do they occur, etc. etc.repeat with theMessage in selectedMessages
This references the variableselectedMessages
, which does not appear anywhere else in the script, so either this isn't the entire script, or this variable hasn't been declared/defined.