mailTabs API

The mailTabs API allows to interact with Thunderbird’s main mail window.

Functions

create([createProperties])

– [Added in TB 121]

Creates a new mail tab. Standard tab properties can be adjusted via update([tabId], updateProperties) after the mail tab has been created. Note: A new mail window can be created via create([createData]).

Parameters

[createProperties]

(MailTabProperties, optional)

Return type (Promise)

Details about the created mail tab. Will contain the ID of the new tab.

get(tabId)

Get the MailTab properties of a mail tab.

Parameters

tabId

(integer)

ID of the requested mail tab. Throws if the requested tabId does not belong to a mail tab.

Return type (Promise)

getCurrent()

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

Return type (Promise)

This may return undefined

getListedMessages([tabId])

– [Added in TB 121]

Lists the messages in the current view, honoring sort order and filters.

Parameters

[tabId]

(integer, optional)

Defaults to the active tab of the current window.

Return type (Promise)

Required permissions

  • messagesRead

getSelectedFolders([tabId])

– [Added in TB 128]

Lists the selected folders in the folder pane.

Parameters

[tabId]

(integer, optional)

Defaults to the active tab of the current window.

Return type (Promise)

array of MailFolder

Required permissions

  • accountsRead

getSelectedMessages([tabId])

Lists the selected messages in the current folder.

Parameters

[tabId]

(integer, optional)

Defaults to the active tab of the current window.

Return type (Promise)

Required permissions

  • messagesRead

query([queryInfo])

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

Parameters

[queryInfo]

(object, optional)

[active]

(boolean, optional)

Whether the tabs are active in their windows.

[currentWindow]

(boolean, optional)

Whether the tabs are in the current window.

[lastFocusedWindow]

(boolean, optional)

Whether the tabs are in the last focused window.

[windowId]

(integer, optional)

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

Return type (Promise)

array of MailTab

setQuickFilter([tabId], properties)

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

Parameters

[tabId]

(integer, optional)

Defaults to the active tab of the current window.

properties

(object)

[attachment]

(boolean, optional)

Shows only messages with attachments.

[contact]

(boolean, optional)

Shows only messages from people in the address book.

[flagged]

(boolean, optional)

Shows only flagged messages.

[show]

(boolean, optional)

Shows or hides the Quick Filter bar.

[tags]

(boolean or TagsDetail, optional)

Shows only messages with tags on them.

[text]

(QuickFilterTextDetail, optional)

Shows only messages matching the supplied text.

[unread]

(boolean, optional)

Shows only unread messages.

setSelectedMessages([tabId], messageIds)

Selects none, one or multiple messages.

Parameters

[tabId]

(integer, optional)

Defaults to the active tab of the current window.

messageIds

(array of MessageId)

The IDs of the messages, which should be selected. The mail tab 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

update([tabId], updateProperties)

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

Parameters

[tabId]

(integer, optional)

Defaults to the active tab of the current window.

updateProperties

Return type (Promise)

Details about the updated mail tab.

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

FolderMode

A supported folder mode in the folder pane.

string

Supported values:

all

unified

tags

unread

favorite

recent

MailTab

object

active

(boolean)

id

(integer)

layout

(string)

The arrangement of the folder pane, message list pane, and message display pane.

Supported values:

standard

wide

vertical

windowId

(integer)

[displayedFolder]

(MailFolder, optional)

The folder displayed in the mail tab. The accountsRead permission is required for this property to be included.

[folderMode]

(FolderMode, optional)

– [Added in TB 125]

The folder mode of the currently displayed folder.

[folderModesEnabled]

(array of FolderMode, optional)

– [Added in TB 125]

The enabled folder modes in the folder pane, and their sort order.

[folderPaneVisible]

(boolean, optional)

Whether the folder pane is visible or not.

[messagePaneVisible]

(boolean, optional)

Whether the message pane is visible or not.

[sortOrder]

(string, optional)

The sort order of the message list.

Supported values:

none

ascending

descending

[sortType]

(string, optional)

The primary sort column of the message list.

Supported values:

none

date

subject

author

id

thread

priority

status

size

flagged

unread

recipient

location

tags

junkStatus

attachments

account

custom

received

correspondent

[viewType]

(string, optional)

– [Added in TB 91]

Grouping type of the message list.

Supported values:

ungrouped

groupedByThread

groupedBySortType

MailTabProperties

object

[displayedFolder]

(MailFolderId or MailFolder, optional)

Sets the folder displayed in the mail tab. Requires the accountsRead permission. The previous message selection in the given folder will be restored, if any.

[folderMode]

(FolderMode, optional)

– [Added in TB 125]

Sets the currently used folder mode, enabling it if required. If used without also specifying displayedFolder, the currently selected folder is re-selected in the new folder mode, if possible.

[folderModesEnabled]

(array of FolderMode, optional)

– [Added in TB 125]

Set the enabled folder modes in the folder pane, and their sort order.

[folderPaneVisible]

(boolean, optional)

Shows or hides the folder pane.

[layout]

(string, optional)

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, optional)

Shows or hides the message display pane.

[sortOrder]

(string, optional)

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

Supported values:

none

ascending

descending

[sortType]

(string, optional)

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, optional)

Sets the grouping type of displayed messages.

Supported values:

ungrouped

groupedByThread

groupedBySortType

QuickFilterTextDetail

object

text

(string)

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

[author]

(boolean, optional)

Shows messages where text matches the author.

[body]

(boolean, optional)

Shows messages where text matches the message body.

[recipients]

(boolean, optional)

Shows messages where text matches the recipients.

[subject]

(boolean, optional)

Shows messages where text matches the subject.