hotkey to send email to specific folder

I noticed there are new mail scripts with the update. I’ve gone into the “Scripts/Mail” folder to look at possibly altering one. My old script that sent an email to a specific DTP folder using a keyboard command (Alfred) has been broken for several weeks and I’d like to try to restore it using one of the new ones. But I’m not fluent in script…

  • I’m assuming this would be fairly easy, right?

  • Could you help me identify the specific section of the right script to add the location of my DTP folder?

  • One thought… For myself, it would be helpful if these scripts had a few (more) notes within them to help quickly identify their purpose, function, etc. When I look at the 3 or 4 new ones in that “scripts/mail” folder I feel some uncertainty. So the non-hierarchical script sends it to…the inbox?

  • My goal: I have Mail-Act-On and would like to have a keyboard stroke send my email to a DTP folder.

In this case, yes… but it’s not an assumption you should generally make.

I don’t know what “the right script” is. You said you had a broken one but not what script it is.

Are you referring to comments about the script as a whole or comments on certain lines to show what the code is doing?

If a location isn’t specified, like “incoming group of current database”, etc. it will go to the destination set in DEVONthink’s Preferences > Import > Destination.

I’m sorry about any confusion with my questions…

I was asking for help in identifying the right script to use…
So… I had been looking in the “Scripts/Mail” folder where there are 4 DTPO scripts, which I’m assuming are the newly revised scripts mentioned in the update:

Mail Rule - Add attachments to DEVONthink Pro
Mail Rule - Add messages to DEVONthink Pro
Mail Rule - File messages & attachments hierarchically
Mail Rule - File messages & attachments

The update sent out several days ago referred to new scripts… Are these the ones? Looking at them, my guess is that the one I need is the 3rd. But there is uncertainty. Do the others only send files to the inbox? Is there also one that copies over mail folders? I wasn’t totally sure the 3rd matched up with the File menu command under Messages in Mail.

This also led to my comment about including one or two extra notes. Having a bit more information to reference would cut down the time I have to put into figuring them out. I want to spend as little time doing software surgery as possible. I do value DTP and I also value having a hotkey to send my mail messages into the exact “bulk” folder where I keep the most important for reference. This workflow generally reduces friction and makes me less likely to skip the archiving that I need to do.

The Mail Rules are not meant for being triggered via a hotkey. You should be looking at ~/Library/Scripts/Applications/Mail, likely the Add message(s) & attachments to DEVONthink.scpt. This script honors the Import Destination preference.

Would you mind providing us with a rather elaborative description of how to use and, even more importantly, how to appropriately modify the respective Mail Scripts?

Documentation is key in almost anything we do? Please go about it or at least link to a place where we will find approved instruction on how to modify the Mail Scripts.


I realize that the question was directed to Jim, however perhaps this will be helpful.

There is info in the DEVONthink manual that briefly covers the function of the scripts. Look in the section ‘Folder Actions, Mail Rules, PDF Services’.

The developers cannot possibly anticipate every workflow scenario or user experience with scripting that the collective user base may have with respect to modifying the scripts. The names of the scripts pretty much describes what they do, try selecting some email(s) and test the scripts.

You can test with about any email, even items in your spam folder. Or send yourself some emails and include dummy documents as attachments to test with. Delete the test emails that you imported when you are done, and if the scripts don’t exactly do what you want, post questions here on how they might possibly be modified so they do give you the results you want. Hope this helps.

The Mail Rules are not meant for being triggered via a hotkey.

Why not?

I did have things set up this way with an Alfred workflow for about 4 months until my script broke (due to an update??). A simple keystroke sent the email message to a specific folder in DTPO where I put all my important messages. That same script then deleted the original from Mail. This was a great workflow. I was at “inbox zero” everyday.

I recently purchased Mail Act-On for Mail as it speeds up my tagging in Apple Mail. This plugin also also for a hotkey to run an Apple Script like Alfred. I don’t care which one gets used as long as I can get it working.

Comment: My father purchased the first Macintosh in 1984, and I’ve been an Apple user ever since that time (I was 14 at the time). The current Apple Mail program runs counter to the generally good experiences I’ve had. I find it baffling because it’s not user friendly, it has bugs (try making the junk rules work), and it’s slow (doesn’t work well with Gmail)…ugh. I would leave it in a split second if I could get the above workflow to function with another app (I wish I could use Canary). If there is a way that anyone can point me toward on this forum, I would be very happy.

Because Mail Rules are specifically coded for use in… Mail Rules.

Re: Apple Mail… I’ve never seen any bad behavior with Gmail in Apple Mail and I’ve been using it exclusively for many years. And it’s certainly the best of breed when it comes to inter-application communication. Other email clients do not provide for good data sharing or automation.

Maybe Mail is running better in High Sierra…but I’ve had a lot of problems (Sierra). I kept thinking that I didn’t know how to use the junk mail rules until I did a search online and found out that I wasn’t the only person struggling with it.

It’s good to hear from people in the know that Mail is solid “under the hood,” at least in fundamental aspects (excluding the junk filter). User friendliness is more subjective. I feel the app isn’t great on this score. That’s just my opinion. However, it’s not the most important thing to me, either.

  • Nate

Indeed. There is much subjectivity in applications’ operation and UI, and I appreciate you acknowledging that fact. (Too many people get waaaay too excited and dogmatic about things like UI.)

Mail Rules are indeed not as consistent as we’d like, but they generally work well enough. (And not many people use or know about them.) However, Pro Office’s Mail plugin can be useful to archive a mailbox into a DEVONthink database. Subsequent (like daily) runs of the Archive Mailbox only pull in unimported emails. You may want to look at that. Cheers!

Good news. My original script was not actually broken and I got it to work with the Act-On plugin. So now I’m cruising again with my workflow. I tag my message, hit my keyboard shortcut, and it exports to the DTPO archive folder. It’s working smoothly. Whew. :slight_smile:

I’m slowing learning the Mail rules… but have a ways to go.


Glad to hear it. Cheers! :smiley: