Import mail from Thunderbird

Looks like it will work like a charm for a moment, but then I get “Devonthink is not allowed assistive access.” I have DT allowed to control other apps in Security and Privacy settings. Not sure what Assistive setting needs changing.

Check System Preferences > Security & Privacy > Privacy > Accessibility.

Does it work after you’ve checked Accessibility?

Yes, I figured out the Accessibility setting, thanks.

However, it still doesn’t work because there is a problem with the installation of the Inbox in the Finder sidebar.

When I run the script it fails and I get the message “Make sure to have DEVONthink’s “Inbox” in Finder’s sidebar”.

However, Inbox IS in the Finder sidebar. So I removed it in the Finder, then re-installed it via DT’s “Install Add-Ons” menu item.

No success. The Inbox in the Finder sidebar doesn’t seem to be the one I actually use. The sidebar Inbox is empty, whereas my actual DT Inbox has 11 items. And, of course, DT reports that I need to install the Inbox in the FInder sidebar, as I had not already done so.

So, to recap, DT says “install the Inbox in Finder sidebar” and then, after I have done that, says “Install the inbox in the FInder sidebar,” as if nothing has happened. This is an entirely different problem and no reflection on your script, for which, again, many thanks!

1 Like

If you manually use Thunderbird’s menu File > Save As > File and choose the inbox in the dialog does the saved file does not end up in DEVONthink?

As far as I know that’s normal. DEVONthink detects when there’s something to import but files won’t be shown in Finder after they were imported into DEVONthink.

Did you rename the inbox in Finder?

The Inbox alias in the Finder’s sidebar is used for importing. It does not reflect the content in the database.

Thanks. In any event, the main problem remains: DT installs the Inboxin the Finder sidebar but the script says it is not there.

Good point. I should have tried before posting.

The Inbox in the Finder sidebar is working correctly – that is, an item dragged to it via Finder appears in DT’s global inbox as expected.

So I guess the problem is that something in the script makes DT think that the Finder inbox icon is not installed.

This has taught me, however, that I can simply drag material from an email into the Inbox (either Finder sidebar’s or DT’s). Not as seamless as a “Send to Devonthink” operation but it will work.

Thanks again!

What about just printing to PDF and then placing the PDF in DT?

Here’s a new version that doesn’t rely on the presence of the inbox alias in the sidebar.

It does rely on the macOS shortcut ⇧⌘G that opens a sheet in save dialogs in which the user can type a path. So if you’re using this shortcut e.g. in Keyboard Maestro make sure your macro doesn’t overwrite the shortcut in Finder.

Please give it a try.

-- Import selected Thunderbird mail(s) into DEVONthink inbox

set thePath to POSIX path of (path to application support from user domain) & "DEVONthink 3/Inbox"

activate application "Thunderbird"
tell application "System Events"
	tell process "Thunderbird"
			set theMenuItem to a reference to menu item 1 of menu 1 of menu item 7 of menu 1 of menu bar item 3 of menu bar 1
			if enabled of theMenuItem = false then error "Please select some mails"
			click theMenuItem
			set foundDialog to false
			repeat 20 times
				if subrole of window 1 = "AXDialog" then
					set foundDialog to true
					exit repeat
					delay 0.1
				end if
			end repeat
			if foundDialog = false then error "No dialog found"
				keystroke "g" using {command down, shift down}
				set foundSheet to false
				repeat 20 times
					if sheet 1 of window 1 exists then
						set foundSheet to true
						exit repeat
						delay 0.1
					end if
				end repeat
				if foundSheet = false then error "No sheet found"
				set value of combo box 1 of sheet 1 of window 1 to thePath
				key code 36
				delay 0.2
				key code 36
			on error
				error "Can't set path in sheet"
			end try
		on error error_message number error_number
			if the error_number is not -128 then
				tell application id "DNtp"
					display alert "Thunderbird" message error_message as warning
				end tell
			end if
		end try
	end tell
end tell
tell application id "DNtp" to activate

I do a version of this now – copying text in the email and pasting it into a new document in DT. I was hoping for something that would let me stay in the email app and send material of interest to DT for later consideration. In Evernote (which has a simple “Send to Evernote” feature) I’ve found this ability quite handy. But perhaps it’s not worth the time & effort to try to impose a procedure from one app onto another. As you suggest there are certainly other ways to move the information.

That works! Thank you very much for taking the time. I really appreciate it.

And sorry for the delayed feedback. Press of work this week, I only now had a chance to try it.


1 Like

Maybe, this is a solution for you?

May I ask why you think any Thunderbird user should do this setup if it’s already possible …

… with the simple script I posted above?

of course: If the integration process works well, as you shared, then that’s great. Less steps, good to go. The solution I shared is a general solution that works across all mail clients, because all of them support IMAP. The setup is actually very straightforward, as the whole thing gets delivered in a docker container, to which you then connect your different email clients. Also, people were suggesting copying text or using pdf - which I feel is much inferior to having the actual mails in DTP.

This is a great script - thank you Pete31. Question: the path prompt appears and vanishes rather quickly, then the message goes to my inbox. I thought I would have control via the path dialog box?


That’s how it should be. The script imports to DEVONthink’s global inbox.

No, that’s not how the script works.

If you want to import to a specific group you have two options:

Option 1 - Smart Rule

Create a Smart Rule that moves the mails from the global inbox to the desired database inbox (or any other group).

Option 2 - Indexed folder

  • Create an indexed group (search DEVONthink’s help for “indexing” and “indexed”).
  • In Finder: Copy the path of the indexed group’s folder (use contextual menu while pressing ⌥)
  • In the script: Set variable thePath to the copied path, e.g.:

set thePath to "/Users/Username/Desktop/My indexed folder"

This option doesn’t work with a database’s inbox as you can’t index an inbox.

I didn’t test this option but it should work.

@pete31 maybe I’m missing something, but the script doesn’t work for me. I have a Global Inbox /Inbox folder, how should I activate that ? Using shift + cmd + G in Thunderbird didn’t anything.

Did you use Thunderbird menu File > Save As > File before you tried that shortcut?

What happens when you run it? The script should display error messages if something goes wrong. Please post the exact text of the error message (or a capture).

Saving as file in the “Inbox” folder (I’m using the DT addon that create the inbox folder in the filesystem) showed the message correctly in the DT inbox, so nevermind I’m fine like this. Thanks