Every week, I receive an email message that contains an attachment and a URL embedded in the body of the message.
I’m wondering if it is possible for KM to trigger when I receive the message in Apple Mail, then save the attachment to a specific folder and save the URL to Pocket.
I've provided a new working macro in addition to the previously posted AppleScript.
Tested only on macOS 10.12.6 so far.
As for saving URLs to Pocket...
Getting URLs out of Mail is not too big a task, but you need to know what kind of URLs you're dealing with.
Is it a plain-text link?
Is it an embedded link?
Plain text is simple to deal with. You can extract that easily with an AppleScript like this:
----------------------------------------------------------------
tell application "Mail"
set selectedMessageList to selection
if length of selectedMessageList ≠ 1 then error "More than 1 message was selected!"
set theMessage to item 1 of selectedMessageList
tell theMessage
set msgContent to its content
return msgContent
end tell
end tell
----------------------------------------------------------------
Embedded links on the other hand get quite a bit more complicated.
Once you have the desired URL then sending to Pocket via script looks like it's not overly difficult.
As a variation on this theme, each day I manually activate a macro that selects all items in the inbox and drag them to the desktop, then switches back to Mail to delete the just copied to the Desktop contents.
If Mail's AppleScripts triggering is unreliable could KM monitor some system level notification of arriving mail and give me the option to move it to the desktop or just move it if I've not been active for X period of time?