Import mail from Thunderbird

Hi, all,
I use Thunderbird as my email client and would like a simple way to move emails from that app into a DT 3 database. I don’t want to put whole mailboxes into DT.

I have seen some discussions of how to get a single email from a non-Mail client, or from Gmail on the web, into DT, but I haven’t understood them. Could someone please explain how to do this? If you use terms like WebDAV and Zapier, please explain them. I have no idea what those things are.

Thanks in advance for any help on this.

David

I would try to explain but I’ve no idea what you’re referring to. Could you post links to the discussions you’ve read?

Thunderbird doesn’t have good export options built in. Check out their extensions. The ImportExport tools extension may be useful for exporting mailboxes but I couldn’t export a single email correctly with it. You’d have to talk to the extension developer about it.

This script imports selected mail(s) into DEVONthink’s global inbox.

When you want to import mail(s)

  • select them in Thunderbird,
  • go back to DEVONthink,
  • run the script.

Of course it’s easier to use it from within Thunderbird, e.g. via Alfred or Keyboard Maestro.

If you want to import to a specific group create a Smart Rule like this

Smart Rule

1 Like

Wow! Thank you very much, Pete31! Really appreciate this.
D

1 Like

Fair point. I of course looked for an extension that might serve, didn’t find anything. I’ve gotten used to just sending emails to Evernote but I want to do more in DT and less in EN.

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"
		try
			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
				else
					delay 0.1
				end if
			end repeat
			if foundDialog = false then error "No dialog found"
			
			try
				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
					else
						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"
					activate
					display alert "Thunderbird" message error_message as warning
				end tell
				return
			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.

David

1 Like

Maybe, this is a solution for you?

https://discourse.devontechnologies.com/t/email-archiving-solutions-using-a-docker-container-as-an-intermediate-imap-server/56543

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?