I am trying to automate clicking of link in mails with certain criteria. Below is the code I have that searches the mail with criteria word “Get” and if found then try to click link in that email. However, I can only get it to open the mail with that criteria. So need help in getting it to click link in the email without me going to all emails. Thanks!
on run
activate application “Mail”
tell application “Mail”
set myInbox to mailbox “Inbox” of account 3
set myMessages to every message of myInbox
repeat with theMessage in myMessages
open theMessage
set messageContent to content of theMessage
set searchText to "Get"
if messageContent contains searchText then
--Clicking link code would go here
end if
delay 5
-- delete theMessage
close window 1
end repeat
end tell
end run