I want to use a mail rule with the applescript “Mail Rule - Add attachments to DEVONThink” to automate the import of every mail attachment.
This works properly when only one new mail is received. But as soon as two or more mails are received at once, it imports the attachment of the first mail and the same attachment for the second mail. So I’m getting duplicates and the attachment from the second mail isn’t there.
This only happens when the rule is triggered at the reception. When you select two or more mails and then “Apply Rules” it works.
I think this is maybe a bug inside apple mail. When i modify the applescript to show a dialog with the subject of the mail. Then it repeats the same subject when two or more mails are received at once.
Or is it maybe a problem with the “repeat” loop within the applescript?
I believe this is a bug in Apple Mail. I have numerous rules which fail in a similar fashion, invariably when several mails arrive at the same time. This regularly includes Apple Mail applying the rule to a different mail than the one which actually triggered the rule. I have found no solution to this behaviour; as a fallback I have included checks within my scripts to at least determine whether the mail which the script is acting on fulfils the rule criteria. That at least precludes Mail causing damage, but leaves me having to intervene manually. Not exactly the point of automation…
I suspect that the attachments aren’t being downloaded until you perform that manual step. Apple Mail is not very good at automation. For me it works happily when I’m at my Mac, and almost universally fails when I’m not.
I used to use Postbox; I think I only stopped because there was no obvious advantage to using Mail. That was in the days before I was playing with automation. Perhaps I’ll go back to trying that. No plugin, of course - but assuming drag and drop to DT works, that should be ok. If I do go back, I’ll post here how the experience was.
So, I have just tried Postbox; on the positive side, my 6 year old license still works. On the negative side, support for AppleScript is so rudimentary that it is not obviously possible to handle mails selected by a filter (rule) using AS (so the equivalent of perform mail action with messages is unavailable). It also doesn’t seem to be possible to use a filter (rule) to save a mail to a Finder folder from where DT could help itself to the mail. So all in all whilst the interface is nice, fast things are easy to set up, Postbox isn’t going to solve this problem, unfortunately. I anybody comes across a reliable, scriptable mail client, do let me know…