compose

This message composition window API first appeared in Thunderbird 67 (see bug 1503423).

Permissions

  • compose “Read and modify your email messages as you compose and send them”

Functions

beginNew([details])

Changed in Thunderbird 77: return value added

Returns a Promise fulfilled with:

beginReply(messageId, [replyType], [details])

Changed in Thunderbird 77: return value added

  • messageId (integer) The message to reply to, as retrieved using other APIs.
  • [replyType] (string)
  • [details] (ComposeDetails) Added in Thunderbird 76

Returns a Promise fulfilled with:

Values for replyType:

  • replyToSender
  • replyToList
  • replyToAll

beginForward(messageId, [forwardType], [details])

Changed in Thunderbird 77: return value added

  • messageId (integer) The message to forward, as retrieved using other APIs.
  • [forwardType] (string)
  • [details] (ComposeDetails)

Returns a Promise fulfilled with:

Values for forwardType:

  • forwardInline
  • forwardAsAttachment

getComposeDetails(tabId)

Added in Thunderbird 74

Fetches the current state of a compose window. Currently only a limited amount of information is available, more will be added in later versions.

  • tabId (integer)

Returns a Promise fulfilled with:

Note

The permission compose is required to use getComposeDetails.

setComposeDetails(tabId, details)

Added in Thunderbird 74

Updates the compose window. Specify only fields that you want to change. Currently only the to/cc/bcc/replyTo/followupTo/newsgroups fields and the subject are implemented.

Note

The permission compose is required to use setComposeDetails.

listAttachments(tabId)

Added in Thunderbird 78

Lists all of the attachments of the message being composed in the specified tab.

  • tabId (integer)

addAttachment(tabId, data)

Added in Thunderbird 78

Adds an attachment to the message being composed in the specified tab.

  • tabId (integer)
  • data (object)
    • file (File)
    • [name] (string) The name, as displayed to the user, of this attachment. If not specified, the name of the file object is used.

updateAttachment(tabId, attachmentId, data)

Added in Thunderbird 78

Renames and/or replaces the contents of an attachment to the message being composed in the specified tab.

  • tabId (integer)
  • attachmentId (integer)
  • data (object)
    • [file] (File)
    • [name] (string) The name, as displayed to the user, of this attachment. If not specified, the name of the file object is used.

removeAttachment(tabId, attachmentId)

Added in Thunderbird 78

Removes an attachment from the message being composed in the specified tab.

  • tabId (integer)
  • attachmentId (integer)

Events

onBeforeSend(tab, details)

Added in Thunderbird 74

Fired when a message is about to be sent from the compose window.

Event listeners should return:

Note

The permission compose is required to use onBeforeSend.

onAttachmentAdded(tab, attachment)

Added in Thunderbird 78

Fired when an attachment is added to a message being composed.

onAttachmentRemoved(tab, attachmentId)

Added in Thunderbird 78

Fired when an attachment is removed from a message being composed.

  • tab (Tab)
  • attachmentId (integer)

onIdentityChanged(tab, identityId)

Added in Thunderbird 78.0b2

Fired when the user changes the identity that will be used to send a message being composed.

  • tab (Tab)
  • identityId (string)

Note

The permission accountsRead is required to use onIdentityChanged.

Types

ComposeAttachment

Added in Thunderbird 78

Represents an attachment in a message being composed.

object:

  • id (integer) A unique identifier for this attachment.
  • name (string) The name, as displayed to the user, of this attachment. This is usually but not always the filename of the attached file.
  • getFile() Retrieves the contents of the attachment as a DOM File object.

ComposeDetails

Used by various functions to represent the state of a message being composed. Note that functions using this type may have a partial implementation.

object:

  • [bcc] (ComposeRecipientList)
  • [body] (string)
  • [cc] (ComposeRecipientList)
  • [followupTo] (ComposeRecipientList) Added in Thunderbird 74
  • [identityId] (string) The ID of an identity from the accounts API. The settings from the identity will be used in the composed message. If replyTo is also specified, the replyTo property of the identity is overridden. The permission accountsRead is required to include the identityId. Added in Thunderbird 76
  • [isPlainText] (boolean) Added in Thunderbird 75
  • [newsgroups] (string or array of string) Added in Thunderbird 74
  • [plainTextBody] (string) Added in Thunderbird 75
  • [replyTo] (ComposeRecipientList)
  • [subject] (string)
  • [to] (ComposeRecipientList)

ComposeRecipient

string: A name and email address in the format “Name <email@example.com>”, or just an email address.

OR

object:

  • id (string) The ID of a contact or mailing list from the contacts and mailingLists APIs.
  • type (string) Which sort of object this ID is for.

Values for type:

  • contact
  • mailingList

ComposeRecipientList

Added in Thunderbird 74

string: A name and email address in the format “Name <email@example.com>”, or just an email address.

OR

array of ComposeRecipient: