Thanks, but I think you’re actually overestimating how much I’m overestimating my deep scripting abilities.
What I don’t overestimate is my ability to find simple ways to do what I’d like to do. And I’m certainly not going to re-invent the several wheels that I already see in place to do parts of this via AppleScript.
There are ways for AppleScript to “access […] the different parts of an e-mail” without many, maybe even any, libraries designed by others to do so. And not a lot of it as I envisage it will involve string operations, either (well, complex ones, anyway).
DEVONthink’s consistent, predictable handling of e-mails on import is a very important part of what I think will make this work.
I’m already fleshing out the flow of what I’d like to do, just doing some more manual testing on some of the individual steps to see if it’s actually feasible or not (hence my “might” in my post above), and I’m hoping if I do decide to go ahead I’ll come in at least a few lines short of 1,000.
But one of the potential gotchas in my “cunning plan" is related to the whole inline vs non-inline attachments thing and how Apple Mail muddies those waters, and whether my “one weird trick” will make or break it for general use by others (or if I’ll find the concession acceptable myself).
Stay tuned, if I go ahead, I think I’m going to have fun!
Oh, and I’ll certainly be asking for input as I go – I’m sure I’ll miss a few things.
Sean
UPDATE1: There’s definitely one base gotcha (the one I hint at) which has been discussed before in relation to whether to grab and delete all attachments, or just some, and it’s not entirely Apple’s fault, although they’re a major contributor, in the way they handle bitmap image and single page PDF attachments. I might be prepared to take the compromise inherent in my “solution", but I’m mulling it over. The benefits may outweigh the drawbacks for my use case, but I can certainly envisage that not being the case for others.
UPDATE2: So, lots of progress today, after lots of stalling. Thought I’d be clever and try and work out a regex pattern to split an e-mail message (which I would do in AppleScript via “do shell script”, but hadn’t thought into the details of that) – I probably wasted 3-4 hours mucking around with that with distressingly mild-but-incomplete-success (doesn’t help I have to teach myself the basic basics of regex every time I play with them). Sat down in AppleScript and within an hour was successfully splitting e-mail source into constituent mime parts (when a message is multipart), testing for just the ones I want (“images/", "application/“), and generally playing around with them. Next step is ignoring inline images < an arbitrary estimated size (decided to shortcut and just go by size of the mime part, rather than extracting the size attribute [if that even exists]. At this point, I’m going to start my new topic on where this particular solution is at and heading after I’ve done a bit more experimentation tonight.