Apple Mail Message Action

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.

Too much to ask?

Thanks much.

Hey Alex,

Apple Mail's ability to run an AppleScript via a mail-rule has been notoriously buggy since Mountain Lion.

So. This might be possible but is likely to be a hassle.

I think you're probably better off creating a manually triggered macro.

-Chris

Thanks, Chris!

I don't necessarily need the macro to trigger with the arrival of the message in Apple Mail. I'd be fine to trigger with a keyboard shortcut.

Is there a method in KM for saving a document attachment to a location?

How about for saving a URL to Pocket?

Sorry. I'm a beginner. Just really trying to learn to harness the power of KM.

Thanks, again!

Here's an AppleScript that should do the job:

Just edit the script for your output folder, and put in a Execute an AppleScript action.

Questions?

Hey Alex,

See my Updated Post #4 in this thread:

Save Apple Mail Attachments to a Specific Folder

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.

-Chris

1 Like

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?

Thank you.

Hey Bern,

What's unreliable are AppleScripts that are run from Mail rules.

Manually activated AppleScripts are fine.

-Chris

Ok, thanks Chris.