我正在尝试自动化打开通过电子邮件发送的特定链接的过程。
电子邮件中有多个链接,其中包括一个取消订阅服务的链接,因此打开正确的链接而不是所有链接都很重要。
流程如下:
这是我无法正常工作的:
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
关于我可以做些什么来使这个过程起作用的任何建议?
答案 0 :(得分:0)
您应该获得 AppleScript 段落而不是 Mail.app 段落:
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 (content of eachMessage) as string -- EDITED
set t to paragraphs of t -- ADDED
repeat with i in t
if i starts with "https://stackoverflow.com/questions/67909907/open-links-sent-in-email-using-applescript" then openLocation(i)
end repeat
end repeat
end perform mail action with messages
end using terms from
on openLocation(theURL)
tell application "Safari" to open location theURL
end openLocation