Are there any commands or functions in Thunderbird that assigns a specific tag to a message? I have more than nine tags, so I need more shortcuts.
I have installed the tbkeys add-on: https://github.com/wshanks/tbkeys I'm able to assign commands and functions like func:AddTag and cmd:cmd_addTag, but those adds a brand new tag. I would like to use one of the tags I've already defined.
I would think that assigning a tag to a message is something needed much more often than adding a new tag, so it's strange that I can't find a way of doing it. I looked through the list here: https://hg.mozilla.org/comm-central/file/tip/mail/base/content/mainCommandSet.inc.xhtml But the mailTagMenuItems only has addTag, mangeTags and removeTags.
Are there nothing like AssignTag('NameOfTag')?
You can use ToggleMessageTag(key, addKey) function. This function will add or remove a tag for the selected messages.
Each tag has a key associated with it. The key is derived from the tag, certain characters are replaced by underscores and then Modified UTF-7 encoding is used.
In simple cases, like "mytag", the key and the tag can be the same. But add a space and the tag ("my tag") will be different from the key ("my_tag").
The tag service is responsible for tag management. Using this interface you can add a new tag or get a key for a tag. In JavaScript you can use MailServices.tags from MailServices.jsm to access the tag service.
To assign a "my tag" to selected messages you can use the following code:
ToggleMessageTag(MailServices.tags.getKeyForTag('my tag'), true);
Depending on the second argument, the tag will be either added (true) or removed (false). For the tbkeys, you will need to use "Eval commands".
A more far-sighted way to change message tags is to use Thunderbird WebExtension API. You can use messages API to update tags.