Move email to mailbox-folder (in Apple Mail) -> trigger import to DT

There are tons of posts regarding email->DT. Mostly on importing at once. However I haven’t found anything on my concern:

Is it possible to push emails to (a not running) DT when they get put into a specific folder within the Mail app?

As Apple mail rules only trigger on incoming mails, this way seems to be blocked.

I’am happy for any suggestions!
I’am also open to different approaches along the way: Select email in Apple Mail and trigger import to a not running DT.
I know I could use drag’n’drop to the DT sorter. But this forces DT to be running.

Specs:
Most recent DT3 Pro, DTTG, Apple Mail

Could you describe what your goal is?

Your question to me sounds like you want to import a certain e-mail only when you perform a move action in Mail. But to what extent?

The reason I’m asking is that I think you’ve thought up a workflow to reach that goal, but it might be you can reach that goal with another workflow as well. That’s also what you’re refering to I guess with the sentence:

I understand running DT is a limitation. Why is that?

Thanks for the quick response!

Goal: I’d like to decide what email/email-attachment I push to DT when reading my mails.

My thoughts were triggering this by moving the to pre-defined foder on Apple mail. But I am open to any other way…

I run a rather old macbook with 16G ram as my main dev machine. I try to not keep other (non-work) related apps running.

Welcome @pico_prob

You’re not going to be able to ”push emails to (a not running) DT”. DEVONthink has to be running to import the emails.

@pico_prob

How about File/Save As (pick an option, I just tested “Raw Message Source”) to the DEVONthink Public Inbox Folder. Or create a PDF from the mail. I put a few there and then when DEVONthink launched later, all files were imported to the Global Inbox?

Would an adapted version of this work?

Whether many user would want it, I don’t know, but queuing e-mails in a sorter like service while DT isn’t running could be useful perhaps.

As @rmschne mentioned, the Global Inbox functions that way as it will hold data until DEVONthink is running.

@pico_prob
You can’t run mail rules based on items going into a folder in Mail. There is no criterion for that.
If you’re going to file items in a folder to sequester them for inspection, you can select them and use the mail script via the script menu in the menubar to send them to DEVONthink as needed.

The closest I get so far is:
Drag’n’Drop email or its attachment to the DT inbox in the finder.

Does anybody know some shortcut for this? A quick look into Apple Automator looked promising: There’s an element to save mail attachments to disk. However, I couldn’t find anything on how to save the mail (ie text) itself… Any hints?
Is there a keyboard shortcut (3rd party?) to trigger an automator script? I guess I can google this easily, but any well-proven solutions?
I’ll look into this tomorrow or on the weekend and keep you posted

Not tested but you could try to use Mail‘s menu item „Apply Rule“ (or something like that). If that works assign a shortcut to it.

I saw the item, but haven’t really pursued that, yet:

  • Working with mail rules requries DT to be running.
  • It looks like you can’t select the rule. Hence, you can’t decide if you want the whole mai, or just the attachment.

@pico_prob This is my workflow:

Goal: to easily import selected email (or emails) in Apple Mail into specific places in DT. I do this because I like to group project files together including emails that are associated with that project.

Set up:

  1. Ensure that the Apple Mail Plugin from DT is installed. Devonthink 3>Install Add Ons...

  2. Create a keyboard shortcut for the new DT menu item in Mail.app (i.e. Message>Add to DEVONthink 3). To do this:
    a. Go to your Mac system preferences, choose Keyboard then choose Shortcuts>App Shortcuts.
    b. Click the + to add a new shortcut. Select Mail.app.
    c. In the “Menu Title” add Add to DEVONthink 3. (note this has to match the menubar item and it has “DEVON” in all caps).
    d. Add your shortcut. I use CTRL+OPT+CMD+D.
    e. Now, in Mail.app on the menubar click on Message and check that the correct shortcut has been applied.

  3. In Devonthink, go to Preferences>Import and check “Select group” for Destination.

Use:
In Mail.app, if you want to save the current email that is highlighted, just use the keyboard shortcut, then when the popup appears, CMD-F to jump to the search box to find the group you want it in (TAB to exit search so you can use the arrow keys to select if needed). Hit enter and it’s done.

Where you view mail in threads and have “show related email” enabled, note that selecting a thread will save all the incoming mail but not the sent ones (i.e. the ones you sent in the thread). To save the sent emails, double click on the sent mail to launch it in its own window and use the keyboard shortcut. CMD-W to close the sent email window when done.

Bonus
Mail that is imported handily has the date created as the timestamp of the email message. You could stop there, but I like to rename my emails so it starts with the timestamp, e.g. “2021-01-12 1123 Our scheduled meeting”. I have been labelling all my files this way for decades – it’s useful if you sort by name.

To do this, create a new smart rule in DT that gets activated on the import of an email message.

HTH!

2 Likes

It requires DT running, however this is some fine technique you have there, @Luminary99_0! :grinning: Thank you for the time you put into this post. I am very grateful.

Could you elaborate a bit on your smart rule? I am just discovering the DT world…

BTW: I needed to restart Apple Mail to obtain the shortcut. As your instruction is very detailed, you might want to add this for others.

I was interested in this discussion because I have a similar setup
I move specific email to my “Devonthink” apple-mail folder (Mac, iPad or mail rule)
I also use DT’s excellent Add message(s) & attachments to DEVONthink.scpt

To trigger the import to DT, I wrote this script
It acts for each email in the mail import folder

set MailScript to (load script "/Users/DTLow/Library/Scripts/Applications/Mail/Add message(s) & attachments to DEVONthink.scpt")

tell application id "DNtp" to set theGroup to preferred import destination
tell application "Mail"
	set theFolder to (POSIX path of (path to temporary items))
	set TheMessages to (messages of mailbox "Devonthink" of account "iCloud")
	repeat with theMessage in TheMessages
		MailScript's imPortMessage(theMessage, theFolder, theGroup)
		delete theMessage
	end repeat
end tell

This trigger script can be run manually, but I automated it to run every 5 minutes (Keyboard Maestro)

1 Like

@pico_prob Here’s how I set up my renaming rule:

  1. At bottom left of the sidebar there is a gear icon, click that and choose New Smart Rule.... A pop up will appear.

  2. Give it a name, e.g. `Process email names to include date-time’.

  3. Search in: Databases. Leave all check-boxes unchecked.

  4. Rule: All of the following is true:

    • [Kind] [is] [Email]
  5. Perform the following actions: [On Import]

  6. [Change Name] to:

    • [Sortable Creation Date] [Name]
    • (in order to to get the tokens above you need to right-click (or CTRL-click) in the input space after the word “to” and choose Insert Place Holder > and select the tokens. There are many to choose from.

So it should look like this:

image

HTH!

1 Like

Thank you… I’ll have to restrain myself with those smart rules :laughing:

I think this is the closest solution I have found, yet. Thank you!

Is there a way to trigger the script on DT app start? Maybe with a delay?
Or what about a cron-job that requires DT to be running…?

The script can be adjusted to only import if Devonthink is running
Here’s sample code from How to check if an app is running

on is_running(appName)
	tell application "System Events" to (name of processes) contains appName
end is_running

if is_running("Devonthink 3") then
...
1 Like