Hello,
New today to KM and hoping it can resolve my issue.
I'm trying to automatically detach attachments to incoming eMail (by account) and put the attachments in a local folder. I have an Applescript that does the detaching, except that Mail does not seem to trigger 100% of the time (more like 20% for some reason). I then created an Automator workflow that I understand KM can trigger. However, I am at a loss as to how to get KM to do so? I think the cron option is the one I should use, having the Automator workflow trigger once a minute, but perhaps there is a different KM option I should be choosing? Any advice much appreciated.
I'm not sure I can help, but I want to know if you want KM to monitor the Mail app for incoming messages, (I think that's what you want) or if you want KM to extract attachments from a specific mail folder on demand.
And do you want the KM macro to run in the background while you use your Mac, or is it okay if the KM macro needs to have the Mail app as the visible, active app while it runs.
You use the word "trigger" a lot, but I don't think you are using that word correctly. What you may need to implement is a KM macro that "polls" the Mail app for new messages. A "trigger" is when the KM macro doesn't have to poll intermittently, but rather gets called by the KM Engine. For example, you talk about using the cron trigger, which technically means your macro is polling the Mail app, not actually getting triggered when a message comes in. At least that's the way I use the word "trigger", while others may disagree with me.
Thank you for your kind response. I may very well be using the word 'trigger' incorrectly. I am not currently aware of KM's ability to poll the Mail app for new messages and detach attachments at the same time. If so, that would eliminate the Automator workflow for sure and be a welcome reduction in complexity. Thank you for some clarity around nomenclature and I will review KM's capabilities further for the desired task (it's difficult to say what I need to have happen when I am not yet cognizant of what KM can or cannot fully do).
You'd more likely use KM to run an AppleScript, similar to the one you're already using, on a periodic basis.
Biggest problem will be that your Rule-triggered AS targets incoming messages individually whereas the KM-triggered one won't "know" which are new messages and which have already been processed -- you may have to mark messages somehow, or move them out of the Inbox once done.
I'd actually concentrate on fixing the problem with Mail. Is the Rule that runs the AppleScript only running 20% of the time? Is another Rule getting there first? Are these email in the Inbox (the only mail folder Rules automatically run in) or have they been pre-filtered (maybe server-side) to a different mail folder? Or does the Rule always run but the AS errors 80% of the time? Something else?
Indeed, resolving the problem within Mail would be ideal. But I have been making little headway. Issues started more frequently after the macOS 15.4.1 update, but did exist prior as well. It's just that sometimes the AppleScript Mail is pointed at will fire and sometimes it will not. The exact same email sent once will work, but sent again 5 minutes later will fail - or the reverse (failure, then work). It is maddening. There are three eMail accounts in Mail, each with it's own AppleScript to detach attachments sent to that address (the AppleScripts are identical, just with modified info for each account it's targeting). Your caution on KM not knowing which are new emails and which already processed is well taken. I'll look into that.
Mail used to have a 'detach attachments' option for incoming email, but Apple removed this feature some time ago, requiring complex workarounds to have the functionality back.
Though not a direct answer to your question...
I used Mail Act-On by Small Cubed for years for this purpose. Depending on how good their new application is that is in beta right now called MailMaven I may jump ship to that app.
Kind of sad that Apple killed plug-ins for their Mail app and slowly made it more difficult for developers over the years (which killed Mail Act-On). Mail for me has been subpare and a basic thing like search has been slow and aweful to use. Even with the updates and little it attention it got a couple years ago is still very slow on an M4 Pro computer.
The support and developer responce and implmentation over the past decade plus has been fantastic.
Thank you very much indeed for the pointers and information. I will def look at the options mentioned. So odd that such a simple-seeming task is so difficult to implement!