I’m trying to sync a handful of labels from my Fastmail account to DTP. I don’t want to use a mail client (Mail or Thunderbird) because they mean a lot of fussy overhead and wasted disk space on my tight drive. So I’ve got a command line tool set up to download just the labels I want into mbox files, and it’s set up to run automatically on a regular basis to catch new messages. Simple and effective.
Next step: importing the messages into DTP. If I use the Import > Unix Mailbox command, it works beautifully. However, I really want this fully automated so that my message archive is always ready to go. Thus, I’m trying to use AppleScript. I didn’t see any bundled scripts that did this, and about everything I’m finding in the forum concerns using a mail UA as a critical part of the process. So I’m writing my own.
Now, I’ve been programming for 40-ish years, but I’m terrible with AppleScript; there’s just something about it that I struggle to get my brain around. As a result, I’ve spent probably close to 24 hours banging my head on this. I’ve created a number of variations of my script that got really close to doing what I want but failed in some small way that proved insurmountable.
Here’s where I want to get to:
-
Import mbox file as a group of email messages inside an existing group. I’ll creatively call this existing target group Imported Email.
-
The mbox includes a ton of “Outlook-xxxx.png” items from social media images that the messages have in their .sigs. I don’t care about these, so I want to move them to another existing group we’ll call Ignored Email Items. I’m doing this versus trashing them because I don’t want DTP to keep recreating them on each repeat import. (I have DTP set to skip duplicates during mail import, so I also won’t get a bunch of replicants.)
One of the big thorns I keep brushing up against is how to get the mbox file properly imported. There’s an import path ... to ...
AS command that seems like it should do the trick, but it simply imports the mbox file as an opaque file, rather than importing it as a group of messages. I’m not sure if this is a bug or if it’s the wrong way to do this.
The only way I’ve found to get the import to work is the open ...
AS command. That makes the import happen properly, but it ends up in the global inbox. I can move them from there to my target group in one of the databases by using more AS or a Smart Rule, but this move seems to break the duplicate tracking. I’m not clear as to why, but I suspect it’s because when the import happens, the previous import’s results have been shuttled off to my target group in another database, so DTP isn’t seeing duplicates at that time and thus not skipping those items.
Any suggestions out there how to make this work? I see four possibilities:
- Identify a way that
open ...
can specify a target group rather than just dumping into the inbox. (BTW, I do know you can change the import destination in the settings, but that changes for all imports, which would break a bunch of other things I do.) - Identify a way that
import path ... to ...
can parse and import the messages inside the mbox file instead of just dumping the mbox file itself into group. - Identify some other AS command to do this.
- Identify some entirely different way to do all this that may not even involve AppleScript. For example, I could resort to UI scripting, but that’s super-ugly for obvous reasons. Maybe I need to parse the mbox myself pre-import so DTP can just bring in the email messages. I have ideas, but I feel like I’ve already spent enough time chasing gold on this, so it’s time to ask the pros out there so I can get back to my other work.
I’m all ears to ideas or guidance!