I am putting together an Automator workflow that will allow me to bind a hotkey to a Smart Mailbox listing and effectively automate the task of clicking "Unsubscribe" in emails which have that text string.
So far, I've been marginally successful if the actual URL has the word "unsubscribe" in it. What I would like to do, instead, is find where the word Unsubscribe appears and instead grab only those URLs. So in HTML terms, imagine I am finding a link by its text and then acting on the href
When I use content
I get only the contents of the email but when I use source
I get links. Basically I need a way to map the content to the source.
I hope that makes sense. This is what I have so far:
on run {input, parameters}
set theSource to {}
tell application "Mail"
repeat with aMessage in input
-- source or content
set end of theSource to aMessage's source & return
end repeat
end tell
return theSource as text
end run