mailTabs API

The mailTabs API first appeared in Thunderbird 66 and allows to interact with Thunderbirds main mail window.

The Filter and Layout sample extensions use this API.

Functions

query(queryInfo)

Gets all mail tabs that have the specified properties, or all mail tabs if no properties are specified.

Parameters

queryInfo

(object)

[active]

(boolean)

Whether the tabs are active in their windows.

[currentWindow]

(boolean)

Whether the tabs are in the current window.

[lastFocusedWindow]

(boolean)

Whether the tabs are in the last focused window.

[windowId]

(integer)

The ID of the parent window, or WINDOW_ID_CURRENT for the current window.

Return type (Promise)

array of MailTab

get(tabId)

Get the properties of a mail tab.

Parameters

tabId

(integer)

ID of the requested mail tab. Throws if the requested tab is not a mail tab.

Return type (Promise)

getCurrent()

Get the properties of the active mail tab, if the active tab is a mail tab. Returns undefined otherwise.

Return type (Promise)

update([tabId], updateProperties)

Modifies the properties of a mail tab. Properties that are not specified in updateProperties are not modified.

Parameters

[tabId]

(integer)

Defaults to the active tab of the current window.

updateProperties

(object)

[displayedFolder]

Sets the folder displayed in the tab. The extension must have the accountsRead permission to do this.

[folderPaneVisible]

(boolean)

Shows or hides the folder pane.

[layout]

(string)

Sets the arrangement of the folder pane, message list pane, and message display pane. Note that setting this applies it to all mail tabs.

Supported values:

standard

wide

vertical

[messagePaneVisible]

(boolean)

Shows or hides the message display pane.

[sortOrder]

(string)

Sorts the list of messages. sortType must also be given.

Supported values:

none

ascending

descending

[sortType]

(string)

Sorts the list of messages. sortOrder must also be given.

Supported values:

none

date

subject

author

id

thread

priority

status

size

flagged

unread

recipient

location

tags

junkStatus

attachments

account

custom

received

correspondent

[viewType]

(string)

– [Added in TB 91]

Supported values:

ungrouped

groupedByThread

groupedBySortType

getSelectedMessages([tabId])

Lists the selected messages in the current folder.

Parameters

[tabId]

(integer)

Defaults to the active tab of the current window.

Return type (Promise)

Required permissions

  • messagesRead

setSelectedMessages([tabId], messageIds)

– [Added in TB 106, backported to TB 102.3.3]

Selects none, one or multiple messages.

Parameters

[tabId]

(integer)

Defaults to the active tab of the current window.

messageIds

(array of integer)

The IDs of the messages, which should be selected. The mailTab will switch to the folder of the selected messages. Throws if they belong to different folders. Array can be empty to deselect any currently selected message.

Required permissions

  • accountsRead

  • messagesRead

setQuickFilter([tabId], properties)

Sets the Quick Filter user interface based on the options specified.

Parameters

[tabId]

(integer)

Defaults to the active tab of the current window.

properties

(object)

[attachment]

(boolean)

Shows only messages with attachments.

[contact]

(boolean)

Shows only messages from people in the address book.

[flagged]

(boolean)

Shows only flagged messages.

[show]

(boolean)

Shows or hides the Quick Filter bar.

[tags]

(boolean or TagsDetail)

Shows only messages with tags on them.

Shows only messages matching the supplied text.

[unread]

(boolean)

Shows only unread messages.

Events

onDisplayedFolderChanged

Fired when the displayed folder changes in any mail tab.

Parameters for onDisplayedFolderChanged.addListener(listener)

listener(tab, displayedFolder)

A function that will be called when this event occurs.

Parameters passed to the listener function

tab

(Tab)

Changes in TB 76:

previously just the tab’s ID

displayedFolder

Required permissions

  • accountsRead

onSelectedMessagesChanged

Fired when the selected messages change in any mail tab.

Parameters for onSelectedMessagesChanged.addListener(listener)

listener(tab, selectedMessages)

A function that will be called when this event occurs.

Parameters passed to the listener function

tab

(Tab)

Changes in TB 76:

previously just the tab’s ID

selectedMessages

Required permissions

  • messagesRead

Types

MailTab

object

active

(boolean)

id

(integer)

layout

(string)

Supported values:

standard

wide

vertical

windowId

(integer)

[displayedFolder]

The accountsRead permission is required for this property to be included.

[folderPaneVisible]

(boolean)

[messagePaneVisible]

(boolean)

[sortOrder]

(string)

Note: sortType and sortOrder depend on each other, so both should be present, or neither.

Supported values:

none

ascending

descending

[sortType]

(string)

Note: sortType and sortOrder depend on each other, so both should be present, or neither.

Supported values:

none

date

subject

author

id

thread

priority

status

size

flagged

unread

recipient

location

tags

junkStatus

attachments

account

custom

received

correspondent

[viewType]

(string)

– [Added in TB 91]

Supported values:

ungrouped

groupedByThread

groupedBySortType

QuickFilterTextDetail

object

text

(string)

String to match against the recipients, author, subject, or body.

[author]

(boolean)

Shows messages where text matches the author.

[body]

(boolean)

Shows messages where text matches the message body.

[recipients]

(boolean)

Shows messages where text matches the recipients.

[subject]

(boolean)

Shows messages where text matches the subject.