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

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)

2 Likes