Identifying presence of attachment in smart group


I’m breaking this question out as it is key to a number of other tasks that others have graciously volunteered their knowledge.

I need to, with a previously imported e-mail, determine:

 1.) Does it have an attachment.
 2.) Does that attachment have a specific name or format

This is specifically for Smart Group rules. Or, if there is a way to achieve the equivalent of a smart group with a script this would be useful as a method of last resort.

Finally, and very importantly, I would need to be able to extract the selected attachments and drop them into a folder for processing by a workflow or shell script.


I’d be happy to see Christian step in here and tell us otherwise, but I am rather certain that these three requirements cannot be done with DEVONthink by itself.

There is no predicate that can be set in Smart Groups to determine if an “Mail” document has attachments.

There is no item in the DEVONthink scripting dictionary that recognizes attachments or allows DEVONthink access to the “Mail” document’s attachments – so a DEVONthink script is not a possibility.

If you want to write a script that accesses a mail message’s attachments then write the script to have Mail (or one of the other OS X mail clients) do that task – Mail’s scripting dictionary allows access to attachments. See, for example, the script shipped with DEVONthink “Mail Rule - Add attachments to DEVONthink Pro” which uses Mail to remove the attachment and then hands them over to DEVONthink.

In the long run, it would probably be simpler to import your messages into Mail (to the extent possible) and have Mail’s smart mailboxes do the work for you. (Yes, we know all of your messages cannot be accessed through Mail.)