messages¶
The messages API first appeared in Thunderbird 66.
Note
When the term messageId
is used in these documents, it doesn’t refer to the Message-ID
email header. It is an internal tracking number that does not remain after a restart. Nor does
it follow an email that has been moved to a different folder.
Warning
Some functions in this API potentially return a lot of messages. Be careful what you wish for! See Working with Message Lists for more information.
Permissions¶
Functions¶
list(folder)¶
continueList(messageListId)¶
Returns the next chunk of messages in a list. See Working with Message Lists for more information.
messageListId
get(messageId)¶
Returns a specified message.
messageId
getFull(messageId)¶
Returns a specified message, including all headers and MIME parts.
messageId
getRaw(messageId)¶
Returns the unmodified source of a message as a binary string.
messageId
listAttachments(messageId)¶
Lists all of the attachments of a message.
messageId
getAttachmentFile(messageId, partName)¶
Gets the content of an attachment as a DOM File
object.
messageId
partName
The most simple way to get the content of an attachment is to use the text()
method of the File
object:
let attachments = await browser.messages.listAttachments(messageId);
for (let att of attachments) {
let file = await browser.messages.getAttachmentFile(
message.id,
att.partName
);
let content = await file.text();
}
query(queryInfo)¶
Gets all messages that have the specified properties, or all messages if no properties are specified.
queryInfo
author
]body
]flagged
]fromMe
]fullText
]headerMessageId
]recipients
]subject
]toMe
]unread
]update(messageId, newProperties)¶
Marks or unmarks a message as read, flagged, or tagged.
messageId
newProperties
flagged
]junk
]read
]tags
]move(messageIds, destination)¶
Moves messages to a specified folder.
messageIds
copy(messageIds, destination)¶
Copies messages to a specified folder.
messageIds
delete(messageIds, [skipTrash])¶
Deletes messages, or moves them to the trash folder.
messageIds
skipTrash
]archive(messageIds)¶
Archives messages using the current settings.
messageIds
listTags()¶
Returns a list of tags that can be set on messages, and their human-friendly name, colour, and sort order.
Events¶
onNewMailReceived(folder, messages)¶
Fired when a new message is received, and has been through junk classification and message filters.
Types¶
Attachment¶
Represents an attachment in a message.
contentType
name
partName
size
MessageHeader¶
Basic information about a message.
author
bccList
ccList
date
flagged
headerMessageId
id
junk
junkScore
read
recipients
subject
tags
MessageList¶
See Working with Message Lists for more information.
MessagePart¶
Represents an email message “part”, which could be the whole message
body
]contentType
]headers
]name
]partName
]size
]MessageTag¶
color
key
ordinal
tag
TagsDetail¶
Used for filtering messages by tag in various methods. Note that functions using this type may have a partial implementation.
mode
Whether all of the tag filters must apply, or any of them.
Supported values:
all
any
tags
true
if the message must have the tag, or false
if it must not have the tag. For a list of available tags, call the listTags() method.