7

Thunderbird 24.2.0 has a -mail command-line parameter, with which a specific mail can be opened from the command line:

$ thunderbird --help
-mail <URL>        Open the message specified by this URL.

I know that one can use this function to open a specific email by an imap:// URI, but I would like to be able to open a specific mail by its unique Message-ID, no matter which folder contains it. Is this possible, and if so, what does the URI look like?

The thunderlink add-on ( https://addons.mozilla.org/en-us/thunderbird/addon/thunderlink/ ) can create message-id based links to emails and then open these with the -thunderlink parameter, but I would still like to know if this can be done with just the -mail parameter.

1
1

Opening messages with the -mail command line parameter is still possible with a current Thunderbird version (tested on Windows 10 with version 78.6.0, 32-bit).

However, this requires a small change of the module MailNewsCommandLineHandler.jsm, because otherwise a getter-only error occurs when calling the -mail command. The error can be traced via the Thunderbird error console (see below).

Adjusting the module:

  1. Copy the file c:\Program Files (x86)\Mozilla Thunderbird\omni.ja into a temporary directory, rename the file to omni.zip and unpack it.

  2. Open MailNewsCommandLineHandler.jsm, insert

    set _messenger(value) {
        return value;
    }, 
    

    after line 22 and save the file.

  3. Repack all files using the following parameters: zip.exe -0DXqr omni.ja *. Rename the original file to omni.ja.bak and copy the repacked file to c:\Program Files (x86)\Mozilla Thunderbird.

  4. Messages can then be opened using the following command lines:

    thunderbird.exe -mail "mailbox-message://<folderLocation>#<messageKey>" (for local folders)
    thunderbird.exe -mail "imap-message://<folderLocation>#<messageKey>" (for IMAP folders)
    

Finding the right URL:

  • Error console: Open TB, select a message and open the error console (Ctrl + Shift + J). Enter the line

    var hdr = gFolderDisplay.selectedMessage; alert(hdr.folder.getUriForMsg(hdr));
    

    and press enter. This will open a window with the URL for the selected message.

  • SQLite database: If you plan to build your own search tool (e.g. by writing a Python plugin for the Wox desktop launcher), it is perhaps best to create the URLs dynamically.

    The Thunderbird database can be found under %APPDATA%\Thunderbird\Profiles\<profile>\global-messages-db.sqlite. The tables messagesText_content, messages and folderLocations contain all information needed to assemble the URL strings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.