I am trying to automate the process of opening specific links that are sent by email.
The email has multiple links in it including one to unsubscribe from the service, so opening the correct link and not all links is important.
The process flow would be:
- Email comes in and triggers rule
- Rule looks for two parameters: email from address and key phrase in email body (not the link)
- Rule moves email to a specific mailbox and then triggers AppleScript
- AppleScript searches for the start of a specific URL and opens it in browser (I manually review open browser tabs at my convenience during the day)
- Email marked as read
This is what I have that is not working correctly:
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
repeat with eachMessage in theMessages
tell application "Mail" to set t to paragraphs of the content of eachMessage
repeat with i in t
if i starts with "http://www.website.com/specific/link" then tell application "Safari" to open location i
end repeat
end repeat
end perform mail action with messages
end using terms from
Any suggestion on what I can do to make this process work?
You should get AppleScript paragraphs instead of Mail.app paragraphs: