Thunderbird – using tbkeys to move messages to specific folders

When I started using Thunderbird a few years back I brought a specific folder setup and wanted to keep using it. So rather than fitting in with Thunderbird’s default “junk” and “archive” behaviours, I wanted to have specific key bindings that moved messages to specific, custom folders.

I followed the guide on this blog post to use tbkeys (the full version, not the lite version) to map two custom key combinations, one for my “junk” folder and one for my “archive” folder:

{
  "command+shift+s":
    "Components.utils.import('resource:///modules/MailUtils.jsm');
    window.goDoCommand('cmd_moveMessage', MailUtils.getExistingFolder( 'imap://USER@SERVER.HOST.NAME/CONFIRMED_JUNK_FOLDER' ) );",
  "command+shift+a": 
    "Components.utils.import('resource:///modules/MailUtils.jsm');
    window.goDoCommand('cmd_moveMessage', MailUtils.getExistingFolder( 'imap://USER@SERVER.HOST.NAME/ARCHIVE_FOLDER' ) );"
}

However with a recent Thunderbird update my tbkeys configuration stopped working. It seems Thunderbird’s ESMification had removed the utility module I was loading and the function I was using to do so. Errors like Components.utils.import is not a function and Failed to load resource:///modules/MailUtils.jsm are an indication you are in the same pickle.

After a bit of troubleshooting and internet searching I finally came up with a new tbkeys config that works:

{
  "command+shift+s": 
    "var { MailUtils } = ChromeUtils.importESModule('resource:///modules/MailUtils.sys.mjs');
    window.goDoCommand('cmd_moveMessage', MailUtils.getExistingFolder( 'imap://USER@SERVER.HOST.NAME/CONFIRMED_JUNK_FOLDER' ) );",
  "command+shift+a": 
    "var { MailUtils } = ChromeUtils.importESModule('resource:///modules/MailUtils.sys.mjs');
    window.goDoCommand('cmd_moveMessage', MailUtils.getExistingFolder( 'imap://USER@SERVER.HOST.NAME/ARCHIVE_FOLDER' ) );"
}
This entry was posted in Uncategorized. Bookmark the permalink. Trackbacks are closed, but you can post a comment.

Post a Comment

Your email is never published nor shared. Required fields are marked *

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*
*